14
14
use Magento \Catalog \Model \Product ;
15
15
use Magento \TestFramework \Helper \Bootstrap ;
16
16
17
+ /**
18
+ * Class for testing fulltext index rebuild
19
+ */
17
20
class FullTest extends \PHPUnit \Framework \TestCase
18
21
{
19
22
/**
20
23
* @var \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full
21
24
*/
22
25
protected $ actionFull ;
23
26
27
+ /**
28
+ * @inheritdoc
29
+ */
24
30
protected function setUp ()
25
31
{
26
32
$ this ->actionFull = Bootstrap::getObjectManager ()->create (
@@ -29,6 +35,8 @@ protected function setUp()
29
35
}
30
36
31
37
/**
38
+ * Testing fulltext index rebuild
39
+ *
32
40
* @magentoDataFixture Magento/CatalogSearch/_files/products_for_index.php
33
41
* @magentoDataFixture Magento/CatalogSearch/_files/product_configurable_not_available.php
34
42
* @magentoDataFixture Magento/Framework/Search/_files/product_configurable.php
@@ -39,7 +47,6 @@ public function testGetIndexData()
39
47
$ productRepository = Bootstrap::getObjectManager ()->get (ProductRepositoryInterface::class);
40
48
$ allowedStatuses = Bootstrap::getObjectManager ()->get (Status::class)->getVisibleStatusIds ();
41
49
$ allowedVisibility = Bootstrap::getObjectManager ()->get (Engine::class)->getAllowedVisibility ();
42
-
43
50
$ result = iterator_to_array ($ this ->actionFull ->rebuildStoreIndex (Store::DISTRO_STORE_ID ));
44
51
$ this ->assertNotEmpty ($ result );
45
52
@@ -58,7 +65,10 @@ public function testGetIndexData()
58
65
}
59
66
60
67
/**
68
+ * Prepare and return expected index data
69
+ *
61
70
* @return array
71
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
62
72
*/
63
73
private function getExpectedIndexData ()
64
74
{
@@ -68,32 +78,48 @@ private function getExpectedIndexData()
68
78
$ nameId = $ attributeRepository ->get (ProductInterface::NAME )->getAttributeId ();
69
79
/** @see dev/tests/integration/testsuite/Magento/Framework/Search/_files/configurable_attribute.php */
70
80
$ configurableId = $ attributeRepository ->get ('test_configurable ' )->getAttributeId ();
81
+ $ statusId = $ attributeRepository ->get (ProductInterface::STATUS )->getAttributeId ();
82
+ $ taxClassId = $ attributeRepository
83
+ ->get (\Magento \Customer \Api \Data \GroupInterface::TAX_CLASS_ID )
84
+ ->getAttributeId ();
71
85
return [
72
86
'configurable ' => [
73
87
$ skuId => 'configurable ' ,
74
88
$ configurableId => 'Option 1 | Option 2 ' ,
75
89
$ nameId => 'Configurable Product | Configurable OptionOption 1 | Configurable OptionOption 2 ' ,
90
+ $ taxClassId => 'Taxable Goods | Taxable Goods | Taxable Goods ' ,
91
+ $ statusId => 'Enabled | Enabled | Enabled '
76
92
],
77
93
'index_enabled ' => [
78
94
$ skuId => 'index_enabled ' ,
79
95
$ nameId => 'index enabled ' ,
96
+ $ taxClassId => 'Taxable Goods ' ,
97
+ $ statusId => 'Enabled '
80
98
],
81
99
'index_visible_search ' => [
82
100
$ skuId => 'index_visible_search ' ,
83
101
$ nameId => 'index visible search ' ,
102
+ $ taxClassId => 'Taxable Goods ' ,
103
+ $ statusId => 'Enabled '
84
104
],
85
105
'index_visible_category ' => [
86
106
$ skuId => 'index_visible_category ' ,
87
107
$ nameId => 'index visible category ' ,
108
+ $ taxClassId => 'Taxable Goods ' ,
109
+ $ statusId => 'Enabled '
88
110
],
89
111
'index_visible_both ' => [
90
112
$ skuId => 'index_visible_both ' ,
91
113
$ nameId => 'index visible both ' ,
114
+ $ taxClassId => 'Taxable Goods ' ,
115
+ $ statusId => 'Enabled '
92
116
]
93
117
];
94
118
}
95
119
96
120
/**
121
+ * Testing fulltext index rebuild with configurations
122
+ *
97
123
* @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
98
124
*/
99
125
public function testRebuildStoreIndexConfigurable ()
@@ -114,6 +140,8 @@ public function testRebuildStoreIndexConfigurable()
114
140
}
115
141
116
142
/**
143
+ * Get product Id by its SKU
144
+ *
117
145
* @param string $sku
118
146
* @return int
119
147
*/
0 commit comments