Completed
Push — master ( 971d31...2154ff )
by Fabian
10:09
created

FulltextIndex   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A ensureTablesAreCreated() 0 4 2
A reindex() 0 6 1
1
<?php
2
3
namespace TddWizard\Fixtures\Catalog;
4
5
use Magento\Indexer\Model\IndexerFactory;
1 ignored issue
show
Bug introduced by
The type Magento\Indexer\Model\IndexerFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Magento\TestFramework\Helper\Bootstrap;
0 ignored issues
show
Bug introduced by
The type Magento\TestFramework\Helper\Bootstrap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
/**
9
 * Can run the fulltext catalog index once from tests to ensure that tables for all stores are created
10
 */
11
class FulltextIndex
12
{
13
    /**
14
     * @var bool
15
     */
16
    private static $created = false;
17
18
    /**
19
     * @var IndexerFactory
20
     */
21
    private $indexerFactory;
22
23
    public function __construct(IndexerFactory $indexerFactory)
24
    {
25
        $this->indexerFactory = $indexerFactory;
26
    }
27
28
    public static function ensureTablesAreCreated()
29
    {
30
        if (! self::$created) {
31
            (new self(Bootstrap::getObjectManager()->create(IndexerFactory::class)))->reindex();
32
        }
33
    }
34
35
    public function reindex()
36
    {
37
        /** @var \Magento\Indexer\Model\Indexer $indexer */
38
        $indexer = $this->indexerFactory->create();
39
        $indexer->load('catalogsearch_fulltext');
40
        $indexer->reindexAll();
41
    }
42
}