Skip to content

Commit c0861d9

Browse files
PHPUnit 12: Fix 3 data provider and method configuration errors
Fixed 3 errors: 1. DateTest: Made providerGetValue() static 2. PaginationProcessorTest: Added setCurPage/setPageSize to onlyMethods 3. CustomizationTest: Replaced self::once()/self::never() with string representations Error #1: Data Provider method not static - providerGetValue() → public static function providerGetValue() Error #2: MethodCannotBeConfiguredException for setCurPage/setPageSize - Added missing methods to onlyMethods() array in AbstractDb mock Error #3: Non-static method self::once() called statically in data provider - Replaced self::once() → 'once', self::never() → 'never' - Added MockCreationTrait import - Used createInvocationMatcher() in test method to convert strings Pattern: For data providers with matcher expectations, use string representations and convert them in test methods with createInvocationMatcher()
1 parent 99ba838 commit c0861d9

File tree

16 files changed

+45
-25
lines changed

16 files changed

+45
-25
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Save/AttributeDateTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\Catalog\Model\Product\Attribute\Save;
99

10+
use PHPUnit\Framework\Attributes\DataProvider;
11+
1012
/**
1113
* @magentoDbIsolation enabled
1214
* @magentoDataFixture Magento/Catalog/_files/product_date_attribute.php
@@ -15,9 +17,9 @@
1517
class AttributeDateTest extends AbstractAttributeTest
1618
{
1719
/**
18-
* @dataProvider productProvider
1920
* @param string $productSku
2021
*/
22+
#[DataProvider('productProvider')]
2123
public function testDefaultValue(string $productSku): void
2224
{
2325
$this->markTestSkipped('Test is blocked by issue MC-28950');
@@ -43,10 +45,10 @@ protected function getDefaultAttributeValue(): string
4345
* @magentoDataFixture Magento/Catalog/_files/product_date_attribute.php
4446
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
4547
* @magentoDataFixture Magento/Catalog/_files/product_simple_out_of_stock.php
46-
* @dataProvider uniqueAttributeValueProvider
4748
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
4849
* @inheritdoc
4950
*/
51+
#[DataProvider('uniqueAttributeValueProvider')]
5052
public function testUniqueAttribute(string $firstSku, string $secondSku): void
5153
{
5254
parent::testUniqueAttribute($firstSku, $secondSku);

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Save/AttributeDropdownTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\Catalog\Model\Product\Attribute\Save;
99

10+
use PHPUnit\Framework\Attributes\DataProvider;
11+
1012
/**
1113
* @magentoDbIsolation enabled
1214
* @magentoDataFixture Magento/Catalog/_files/dropdown_attribute.php
@@ -34,10 +36,10 @@ protected function getDefaultAttributeValue(): string
3436
* @magentoDataFixture Magento/Catalog/_files/dropdown_attribute.php
3537
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
3638
* @magentoDataFixture Magento/Catalog/_files/product_simple_out_of_stock.php
37-
* @dataProvider uniqueAttributeValueProvider
3839
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
3940
* @inheritdoc
4041
*/
42+
#[DataProvider('uniqueAttributeValueProvider')]
4143
public function testUniqueAttribute(string $firstSku, string $secondSku): void
4244
{
4345
parent::testUniqueAttribute($firstSku, $secondSku);

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Save/AttributeMultiSelectTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\Catalog\Model\Product\Attribute\Save;
99

10+
use PHPUnit\Framework\Attributes\DataProvider;
11+
1012
/**
1113
* @magentoDbIsolation enabled
1214
* @magentoDataFixture Magento/Catalog/_files/multiselect_attribute.php
@@ -32,8 +34,8 @@ protected function getDefaultAttributeValue(): string
3234

3335
/**
3436
* @inheritdoc
35-
* @dataProvider productProvider
3637
*/
38+
#[DataProvider('productProvider')]
3739
public function testDefaultValue(string $productSku): void
3840
{
3941
$this->markTestSkipped('Test is blocked by issue MC-29019');

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Save/AttributeTextTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\Catalog\Model\Product\Attribute\Save;
99

10+
use PHPUnit\Framework\Attributes\DataProvider;
11+
1012
/**
1113
* @magentoDbIsolation enabled
1214
* @magentoDataFixture Magento/Catalog/_files/product_varchar_attribute.php
@@ -34,10 +36,10 @@ protected function getDefaultAttributeValue(): string
3436
* @magentoDataFixture Magento/Catalog/_files/product_varchar_attribute.php
3537
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
3638
* @magentoDataFixture Magento/Catalog/_files/product_simple_out_of_stock.php
37-
* @dataProvider uniqueAttributeValueProvider
3839
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
3940
* @inheritdoc
4041
*/
42+
#[DataProvider('uniqueAttributeValueProvider')]
4143
public function testUniqueAttribute(string $firstSku, string $secondSku): void
4244
{
4345
parent::testUniqueAttribute($firstSku, $secondSku);

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Save/AttributeYesNoTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\Catalog\Model\Product\Attribute\Save;
99

10+
use PHPUnit\Framework\Attributes\DataProvider;
11+
1012
/**
1113
* @magentoDbIsolation enabled
1214
* @magentoDataFixture Magento/Catalog/_files/product_boolean_attribute.php
@@ -34,10 +36,10 @@ protected function getDefaultAttributeValue(): string
3436
* @magentoDataFixture Magento/Catalog/_files/product_boolean_attribute.php
3537
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
3638
* @magentoDataFixture Magento/Catalog/_files/product_simple_out_of_stock.php
37-
* @dataProvider uniqueAttributeValueProvider
3839
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
3940
* @inheritdoc
4041
*/
42+
#[DataProvider('uniqueAttributeValueProvider')]
4143
public function testUniqueAttribute(string $firstSku, string $secondSku): void
4244
{
4345
parent::testUniqueAttribute($firstSku, $secondSku);

dev/tests/integration/testsuite/Magento/Framework/View/LayoutTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Magento\Framework\View\Layout\ProcessorInterface;
2525
use Magento\TestFramework\Helper\Bootstrap;
2626
use PHPUnit\Framework\TestCase;
27+
use PHPUnit\Framework\Attributes\DataProvider;
2728

2829
/**
2930
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -215,8 +216,8 @@ public function testSetUnsetBlock(): void
215216

216217
/**
217218
* @return void
218-
* @dataProvider createBlockDataProvider
219219
*/
220+
#[DataProvider('createBlockDataProvider')]
220221
public function testCreateBlock($blockType, $blockName, array $blockData, $expectedName): void
221222
{
222223
$expectedData = $blockData + ['type' => $blockType];
@@ -248,8 +249,8 @@ public static function createBlockDataProvider(): array
248249

249250
/**
250251
* @return void
251-
* @dataProvider blockNotExistsDataProvider
252252
*/
253+
#[DataProvider('blockNotExistsDataProvider')]
253254
public function testCreateBlockNotExists($name): void
254255
{
255256
$this->expectException(LocalizedException::class);
@@ -288,8 +289,8 @@ public function testAddBlock(): void
288289
/**
289290
* @magentoAppIsolation enabled
290291
* @return void
291-
* @dataProvider addContainerDataProvider()
292292
*/
293+
#[DataProvider('addContainerDataProvider')]
293294
public function testAddContainer($htmlTag): void
294295
{
295296
$this->assertFalse($this->layout->hasElement('container'));

dev/tests/integration/testsuite/Magento/Shipping/Helper/DataTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Shipping\Helper;
77

88
use Magento\Store\Model\StoreManagerInterface;
9+
use PHPUnit\Framework\Attributes\DataProvider;
910

1011
class DataTest extends \PHPUnit\Framework\TestCase
1112
{
@@ -27,8 +28,8 @@ protected function setUp(): void
2728
* @param int $entityId
2829
* @param string $code
2930
* @param string $expected
30-
* @dataProvider getTrackingPopupUrlBySalesModelDataProvider
3131
*/
32+
#[DataProvider('getTrackingPopupUrlBySalesModelDataProvider')]
3233
public function testGetTrackingPopupUrlBySalesModel($modelName, $getIdMethod, $entityId, $code, $expected)
3334
{
3435
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
@@ -65,8 +66,8 @@ public function testGetTrackingPopupUrlBySalesModel($modelName, $getIdMethod, $e
6566
* @param string $expected
6667
* @magentoAppArea adminhtml
6768
* @magentoConfigFixture admin_store web/unsecure/base_link_url http://admin.localhost/
68-
* @dataProvider getTrackingPopupUrlBySalesModelDataProvider
6969
*/
70+
#[DataProvider('getTrackingPopupUrlBySalesModelDataProvider')]
7071
public function testGetTrackingPopupUrlBySalesModelFromAdmin($modelName, $getIdMethod, $entityId, $code, $expected)
7172
{
7273
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();

dev/tests/integration/testsuite/Magento/Swatches/Model/AttributeTextSwatchTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Swatches\Model;
99

1010
use Magento\Catalog\Model\Product\Attribute\Save\AbstractAttributeTest;
11+
use PHPUnit\Framework\Attributes\DataProvider;
1112

1213
/**
1314
* @magentoDbIsolation enabled
@@ -36,10 +37,10 @@ protected function getDefaultAttributeValue(): string
3637
* @magentoDataFixture Magento/Swatches/_files/product_text_swatch_attribute.php
3738
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
3839
* @magentoDataFixture Magento/Catalog/_files/product_simple_out_of_stock.php
39-
* @dataProvider uniqueAttributeValueProvider
4040
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
4141
* @inheritdoc
4242
*/
43+
#[DataProvider('uniqueAttributeValueProvider')]
4344
public function testUniqueAttribute(string $firstSku, string $secondSku): void
4445
{
4546
parent::testUniqueAttribute($firstSku, $secondSku);

dev/tests/integration/testsuite/Magento/Swatches/Model/AttributeVisualSwatchTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Swatches\Model;
99

1010
use Magento\Catalog\Model\Product\Attribute\Save\AbstractAttributeTest;
11+
use PHPUnit\Framework\Attributes\DataProvider;
1112

1213
/**
1314
* @magentoDbIsolation enabled
@@ -35,11 +36,11 @@ protected function getDefaultAttributeValue(): string
3536
/**
3637
* @magentoDataFixture Magento/Swatches/_files/product_visual_swatch_attribute.php
3738
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
38-
* @magentoDataFixture Magento/Catalog/_files/product_simple_out_of_stock.php
39-
* @dataProvider uniqueAttributeValueProvider
39+
* @magentoDataFixture Magento/Catalog/_files/product_simple_out_of_stock.php
4040
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
4141
* @inheritdoc
4242
*/
43+
#[DataProvider('uniqueAttributeValueProvider')]
4344
public function testUniqueAttribute(string $firstSku, string $secondSku): void
4445
{
4546
parent::testUniqueAttribute($firstSku, $secondSku);

dev/tests/integration/testsuite/Magento/Widget/Model/Widget/InstanceTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Widget\Model\Widget;
88

9+
use PHPUnit\Framework\Attributes\DataProvider;
10+
911
class InstanceTest extends \PHPUnit\Framework\TestCase
1012
{
1113
/**
@@ -148,9 +150,9 @@ public function testGenerateLayoutUpdateXml(\Magento\Widget\Model\Widget\Instanc
148150
/**
149151
* @covers \Magento\Widget\Model\Widget\Instance::beforeSave()
150152
* @magentoDataFixture Magento/Widget/_files/new_widget.php
151-
* @dataProvider beforeSaveDataProvider
152153
* @param array $expected
153154
*/
155+
#[DataProvider('beforeSaveDataProvider')]
154156
public function testBeforeSave(array $expected)
155157
{
156158
/** @var \Magento\Widget\Model\ResourceModel\Widget\Instance $resourceModel */

0 commit comments

Comments
 (0)