8
8
9
9
use Magento \Bundle \Test \Fixture \Option as BundleOptionFixture ;
10
10
use Magento \Bundle \Test \Fixture \Product as BundleProductFixture ;
11
+ use Magento \Catalog \Model \Product \Attribute \Source \Status as ProductStatus ;
11
12
use Magento \Catalog \Test \Fixture \MultiselectAttribute as MultiselectAttributeFixture ;
12
13
use Magento \Catalog \Test \Fixture \Category as CategoryFixture ;
13
14
use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
20
21
use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
21
22
use Magento \TestFramework \Fixture \DbIsolation ;
22
23
use Magento \TestFramework \Helper \Bootstrap ;
24
+ use PHPUnit \Framework \Attributes \CoversClass ;
23
25
use PHPUnit \Framework \Attributes \DataProvider ;
24
26
use PHPUnit \Framework \TestCase ;
25
27
26
28
/**
27
- * Tests for @see \Magento\CatalogWidget\Block\Product\ProductsList
28
- *
29
29
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
30
30
*/
31
- class ProductListTest extends TestCase
31
+ #[
32
+ CoversClass(ProductsList::class),
33
+ DbIsolation(false ),
34
+ ]
35
+ class ProductsListTest extends TestCase
32
36
{
33
37
/**
34
38
* @var ProductsList
35
39
*/
36
- protected $ block ;
40
+ private $ block ;
37
41
38
42
/**
39
43
* @var CategoryCollection;
40
-
41
44
*/
42
45
private $ categoryCollection ;
43
46
44
47
/**
45
48
* @var ObjectManagerInterface
46
49
*/
47
- protected $ objectManager ;
50
+ private $ objectManager ;
48
51
49
52
/**
50
53
* @var DataFixtureStorage
@@ -56,7 +59,7 @@ protected function setUp(): void
56
59
$ this ->objectManager = Bootstrap::getObjectManager ();
57
60
$ this ->block = $ this ->objectManager ->create (ProductsList::class);
58
61
$ this ->categoryCollection = $ this ->objectManager ->create (CategoryCollection::class);
59
- $ this ->fixtures = Bootstrap:: getObjectManager () ->get (DataFixtureStorageManager::class)->getStorage ();
62
+ $ this ->fixtures = $ this -> objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
60
63
}
61
64
62
65
/**
@@ -67,10 +70,10 @@ protected function setUp(): void
67
70
* 3. Create product list widget condition based on the new multiselect attribute
68
71
* 4. Set at least 2 options of multiselect attribute to match products for the product list widget
69
72
* 5. Load collection for product list widget and make sure that number of loaded products is correct
70
- *
71
- * @magentoDbIsolation disabled
72
- * @magentoDataFixture Magento/Catalog/_files/products_with_multiselect_attribute.php
73
73
*/
74
+ #[
75
+ DataFixture('Magento/Catalog/_files/products_with_multiselect_attribute.php ' ),
76
+ ]
74
77
public function testCreateCollection ()
75
78
{
76
79
// Reindex EAV attributes to enable products filtration by created multiselect attribute
@@ -111,10 +114,10 @@ public function testCreateCollection()
111
114
112
115
/**
113
116
* Test product list widget can process condition with dropdown type of attribute
114
- *
115
- * @magentoDbIsolation disabled
116
- * @magentoDataFixture Magento/Catalog/_files/products_with_dropdown_attribute.php
117
117
*/
118
+ #[
119
+ DataFixture('Magento/Catalog/_files/products_with_dropdown_attribute.php ' ),
120
+ ]
118
121
public function testCreateCollectionWithDropdownAttribute ()
119
122
{
120
123
/** @var $attribute Attribute */
@@ -166,15 +169,15 @@ private function performAssertions(int $count)
166
169
/**
167
170
* Check that collection returns correct result if use not contains operator for string attribute
168
171
*
169
- * @magentoDbIsolation disabled
170
- * @magentoDataFixture Magento/Catalog/_files/product_simple_xss.php
171
- * @magentoDataFixture Magento/Catalog/_files/product_virtual.php
172
- * @dataProvider createCollectionForSkuDataProvider
173
172
* @param string $encodedConditions
174
173
* @param string $sku
175
- * @return void
176
- * @throws \Magento\Framework\Exception\LocalizedException
177
174
*/
175
+ #[
176
+ DataFixture('Magento/Catalog/_files/product_simple_xss.php ' ),
177
+ DataFixture('Magento/Catalog/_files/product_virtual.php ' ),
178
+ DataFixture(ProductFixture::class, ['status ' => ProductStatus::STATUS_DISABLED ]),
179
+ DataProvider('createCollectionForSkuDataProvider ' ),
180
+ ]
178
181
public function testCreateCollectionForSku ($ encodedConditions , $ sku )
179
182
{
180
183
$ this ->block ->setData ('conditions_encoded ' , $ encodedConditions );
@@ -207,12 +210,10 @@ public static function createCollectionForSkuDataProvider()
207
210
208
211
/**
209
212
* Check that collection returns correct result if use date attribute.
210
- *
211
- * @magentoDbIsolation disabled
212
- * @magentoDataFixture Magento/Catalog/_files/product_simple_with_date_attribute.php
213
- * @return void
214
- * @throws \Magento\Framework\Exception\LocalizedException
215
213
*/
214
+ #[
215
+ DataFixture('Magento/Catalog/_files/product_simple_with_date_attribute.php ' ),
216
+ ]
216
217
public function testProductListWithDateAttribute ()
217
218
{
218
219
$ encodedConditions = '^[`1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Combine`, '
@@ -238,10 +239,10 @@ public function testProductListWithDateAttribute()
238
239
* 2. Create 2 new products and assign them to the sub categories
239
240
* 3. Create product list widget condition to display products from the anchor root category
240
241
* 4. Load collection for product list widget and make sure that number of loaded products is correct
241
- *
242
- * @magentoDbIsolation disabled
243
- * @magentoDataFixture Magento/Catalog/_files/product_in_nested_anchor_categories.php
244
242
*/
243
+ #[
244
+ DataFixture('Magento/Catalog/_files/product_in_nested_anchor_categories.php ' ),
245
+ ]
245
246
public function testCreateAnchorCollection ()
246
247
{
247
248
// Reindex EAV attributes to enable products filtration by created multiselect attribute
@@ -276,7 +277,6 @@ public function testCreateAnchorCollection()
276
277
}
277
278
278
279
#[
279
- DbIsolation(false ),
280
280
DataFixture(ProductFixture::class, ['price ' => 10 ], 'p1 ' ),
281
281
DataFixture(ProductFixture::class, ['price ' => 20 ], 'p2 ' ),
282
282
DataFixture(BundleOptionFixture::class, ['product_links ' => ['$p1$ ' , '$p2$ ' ]], 'opt1 ' ),
@@ -301,14 +301,15 @@ public function testBundleProductList()
301
301
/**
302
302
* Test that price rule condition works correctly
303
303
*
304
- * @magentoDbIsolation disabled
305
- * @magentoDataFixture Magento/Catalog/_files/category_with_different_price_products.php
306
- * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
307
304
* @param string $operator
308
305
* @param int $value
309
306
* @param array $matches
310
- * @dataProvider priceFilterDataProvider
311
307
*/
308
+ #[
309
+ DataFixture('Magento/Catalog/_files/category_with_different_price_products.php ' ),
310
+ DataFixture('Magento/ConfigurableProduct/_files/product_configurable.php ' ),
311
+ DataProvider('priceFilterDataProvider ' ),
312
+ ]
312
313
public function testPriceFilter (string $ operator , int $ value , array $ matches )
313
314
{
314
315
$ encodedConditions = '^[`1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Combine`,
@@ -375,7 +376,6 @@ public static function priceFilterDataProvider(): array
375
376
}
376
377
377
378
#[
378
- DbIsolation(false ),
379
379
DataProvider('collectionResultWithMultiselectAttributeDataProvider ' ),
380
380
DataFixture(
381
381
MultiselectAttributeFixture::class,
0 commit comments