88
99use Magento \Bundle \Test \Fixture \Option as BundleOptionFixture ;
1010use Magento \Bundle \Test \Fixture \Product as BundleProductFixture ;
11+ use Magento \Catalog \Model \Product \Attribute \Source \Status as ProductStatus ;
1112use Magento \Catalog \Test \Fixture \MultiselectAttribute as MultiselectAttributeFixture ;
1213use Magento \Catalog \Test \Fixture \Category as CategoryFixture ;
1314use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
2021use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
2122use Magento \TestFramework \Fixture \DbIsolation ;
2223use Magento \TestFramework \Helper \Bootstrap ;
24+ use PHPUnit \Framework \Attributes \CoversClass ;
2325use PHPUnit \Framework \Attributes \DataProvider ;
2426use PHPUnit \Framework \TestCase ;
2527
2628/**
27- * Tests for @see \Magento\CatalogWidget\Block\Product\ProductsList
28- *
2929 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3030 */
31- class ProductListTest extends TestCase
31+ #[
32+ CoversClass(ProductsList::class),
33+ DbIsolation(false ),
34+ ]
35+ class ProductsListTest extends TestCase
3236{
3337 /**
3438 * @var ProductsList
3539 */
36- protected $ block ;
40+ private $ block ;
3741
3842 /**
3943 * @var CategoryCollection;
40-
4144 */
4245 private $ categoryCollection ;
4346
4447 /**
4548 * @var ObjectManagerInterface
4649 */
47- protected $ objectManager ;
50+ private $ objectManager ;
4851
4952 /**
5053 * @var DataFixtureStorage
@@ -56,7 +59,7 @@ protected function setUp(): void
5659 $ this ->objectManager = Bootstrap::getObjectManager ();
5760 $ this ->block = $ this ->objectManager ->create (ProductsList::class);
5861 $ 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 ();
6063 }
6164
6265 /**
@@ -67,10 +70,10 @@ protected function setUp(): void
6770 * 3. Create product list widget condition based on the new multiselect attribute
6871 * 4. Set at least 2 options of multiselect attribute to match products for the product list widget
6972 * 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
7373 */
74+ #[
75+ DataFixture('Magento/Catalog/_files/products_with_multiselect_attribute.php ' ),
76+ ]
7477 public function testCreateCollection ()
7578 {
7679 // Reindex EAV attributes to enable products filtration by created multiselect attribute
@@ -111,10 +114,10 @@ public function testCreateCollection()
111114
112115 /**
113116 * 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
117117 */
118+ #[
119+ DataFixture('Magento/Catalog/_files/products_with_dropdown_attribute.php ' ),
120+ ]
118121 public function testCreateCollectionWithDropdownAttribute ()
119122 {
120123 /** @var $attribute Attribute */
@@ -166,15 +169,15 @@ private function performAssertions(int $count)
166169 /**
167170 * Check that collection returns correct result if use not contains operator for string attribute
168171 *
169- * @magentoDbIsolation disabled
170- * @magentoDataFixture Magento/Catalog/_files/product_simple_xss.php
171- * @magentoDataFixture Magento/Catalog/_files/product_virtual.php
172- * @dataProvider createCollectionForSkuDataProvider
173172 * @param string $encodedConditions
174173 * @param string $sku
175- * @return void
176- * @throws \Magento\Framework\Exception\LocalizedException
177174 */
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+ ]
178181 public function testCreateCollectionForSku ($ encodedConditions , $ sku )
179182 {
180183 $ this ->block ->setData ('conditions_encoded ' , $ encodedConditions );
@@ -207,12 +210,10 @@ public static function createCollectionForSkuDataProvider()
207210
208211 /**
209212 * 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
215213 */
214+ #[
215+ DataFixture('Magento/Catalog/_files/product_simple_with_date_attribute.php ' ),
216+ ]
216217 public function testProductListWithDateAttribute ()
217218 {
218219 $ encodedConditions = '^[`1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Combine`, '
@@ -238,10 +239,10 @@ public function testProductListWithDateAttribute()
238239 * 2. Create 2 new products and assign them to the sub categories
239240 * 3. Create product list widget condition to display products from the anchor root category
240241 * 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
244242 */
243+ #[
244+ DataFixture('Magento/Catalog/_files/product_in_nested_anchor_categories.php ' ),
245+ ]
245246 public function testCreateAnchorCollection ()
246247 {
247248 // Reindex EAV attributes to enable products filtration by created multiselect attribute
@@ -276,7 +277,6 @@ public function testCreateAnchorCollection()
276277 }
277278
278279 #[
279- DbIsolation(false ),
280280 DataFixture(ProductFixture::class, ['price ' => 10 ], 'p1 ' ),
281281 DataFixture(ProductFixture::class, ['price ' => 20 ], 'p2 ' ),
282282 DataFixture(BundleOptionFixture::class, ['product_links ' => ['$p1$ ' , '$p2$ ' ]], 'opt1 ' ),
@@ -301,14 +301,15 @@ public function testBundleProductList()
301301 /**
302302 * Test that price rule condition works correctly
303303 *
304- * @magentoDbIsolation disabled
305- * @magentoDataFixture Magento/Catalog/_files/category_with_different_price_products.php
306- * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
307304 * @param string $operator
308305 * @param int $value
309306 * @param array $matches
310- * @dataProvider priceFilterDataProvider
311307 */
308+ #[
309+ DataFixture('Magento/Catalog/_files/category_with_different_price_products.php ' ),
310+ DataFixture('Magento/ConfigurableProduct/_files/product_configurable.php ' ),
311+ DataProvider('priceFilterDataProvider ' ),
312+ ]
312313 public function testPriceFilter (string $ operator , int $ value , array $ matches )
313314 {
314315 $ encodedConditions = '^[`1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Combine`,
@@ -375,7 +376,6 @@ public static function priceFilterDataProvider(): array
375376 }
376377
377378 #[
378- DbIsolation(false ),
379379 DataProvider('collectionResultWithMultiselectAttributeDataProvider ' ),
380380 DataFixture(
381381 MultiselectAttributeFixture::class,
0 commit comments