Skip to content

Commit 64fa569

Browse files
phpunit updating the callback
1 parent f2a7ead commit 64fa569

24 files changed

Lines changed: 114 additions & 126 deletions

dev/tests/phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* All Rights Reserved.
66
*/
77
-->
8-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" bootstrap="_bootstrap.php" backupGlobals="false" cacheDirectory=".phpunit.cache">
8+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.0/phpunit.xsd" bootstrap="_bootstrap.php" backupGlobals="false" cacheDirectory=".phpunit.cache">
99
<coverage>
1010
<report>
1111
<clover outputFile="build/logs/clover.xml"/>

dev/tests/unit/Magento/FunctionalTestFramework/Allure/AllureHelperTest.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace tests\unit\Magento\FunctionalTestFramework\Allure;
1010

1111
use Magento\FunctionalTestingFramework\Allure\AllureHelper;
12+
use PHPUnit\Framework\Attributes\DataProvider;
1213
use PHPUnit\Framework\TestCase;
1314
use Qameta\Allure\Allure;
1415
use Qameta\Allure\Io\DataSourceFactory;
@@ -27,9 +28,7 @@ public function setUp(): void
2728
Allure::reset();
2829
}
2930

30-
/**
31-
* @dataProvider providerAttachmentProperties
32-
*/
31+
#[DataProvider('providerAttachmentProperties')]
3332
public function testDoAddAttachmentMethod(
3433
string $name,
3534
$type,
@@ -50,9 +49,7 @@ public function testDoAddAttachmentMethod(
5049
self::assertSame('typeOfTheFile', $attachment->getType());
5150
}
5251

53-
/**
54-
* @dataProvider providerAttachmentProperties
55-
*/
52+
#[DataProvider('providerAttachmentProperties')]
5653
public function testAddAttachmentToStep(
5754
string $name,
5855
?string $type,
@@ -69,9 +66,7 @@ public function testAddAttachmentToStep(
6966
self::assertSame($fileExtension, $attachment->getFileExtension());
7067
}
7168

72-
/**
73-
* @dataProvider providerAttachmentProperties
74-
*/
69+
#[DataProvider('providerAttachmentProperties')]
7570
public function testAddAttachmentFileToStep(
7671
string $name,
7772
?string $type,

dev/tests/unit/Magento/FunctionalTestFramework/Console/GenerateTestsCommandTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace tests\unit\Magento\FunctionalTestFramework\Console;
88

99
use PHPUnit\Framework\TestCase;
10+
use PHPUnit\Framework\Attributes\DataProvider;
1011
use Magento\FunctionalTestingFramework\Exceptions\FastFailException;
1112
use Magento\FunctionalTestingFramework\Console\GenerateTestsCommand;
1213

@@ -17,9 +18,9 @@ class GenerateTestsCommandTest extends TestCase
1718
* @param mixed $groups
1819
* @param mixed $expected
1920
* @return void
20-
* @dataProvider configParallelOptions
2121
* @throws \ReflectionException
2222
*/
23+
#[DataProvider('configParallelOptions')]
2324
public function testParseConfigParallelOptions($time, $groups, $expected): void
2425
{
2526
$command = new GenerateTestsCommand();

dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/DataObjectHandlerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ private function mockDataObjectHandlerWithData(array $mockData): void
336336
$mockObjectManagerInstance = $this->createMock(ObjectManager::class);
337337
$mockObjectManagerInstance
338338
->method('create')
339-
->will(
340-
$this->returnCallback(
339+
->willReturnCallback(
341340
function (
342341
string $class,
343342
array $arguments = []
@@ -351,7 +350,6 @@ function (
351350

352351
return $objectManager->create($class, $arguments);
353352
}
354-
)
355353
);
356354

357355
$property = new ReflectionProperty(ObjectManager::class, 'instance');

dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/OperationDefinitionObjectHandlerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ private function mockOperationHandlerWithData(array $mockData): void
518518
$mockObjectManagerInstance = $this->createMock(ObjectManager::class);
519519
$mockObjectManagerInstance
520520
->method('create')
521-
->will(
522-
$this->returnCallback(
521+
->willReturnCallback(
523522
function (
524523
string $class,
525524
array $arguments = []
@@ -533,7 +532,6 @@ function (
533532

534533
return $objectManager->create($class, $arguments);
535534
}
536-
)
537535
);
538536

539537
$property = new ReflectionProperty(ObjectManager::class, 'instance');

dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException;
1818
use Magento\FunctionalTestingFramework\ObjectManager;
1919
use Magento\FunctionalTestingFramework\ObjectManagerFactory;
20+
use PHPUnit\Framework\Attributes\DataProvider;
2021
use ReflectionProperty;
2122
use tests\unit\Util\MagentoTestCase;
2223
use tests\unit\Util\TestLoggingUtil;
@@ -405,11 +406,11 @@ public function testRetrieveEntityAcrossScopes(): void
405406
* @param string $type
406407
* @param string $scope
407408
* @param string $stepKey
408-
* @dataProvider entityDataProvider
409409
*
410410
* @return void
411411
* @throws TestReferenceException
412412
*/
413+
#[DataProvider('entityDataProvider')]
413414
public function testRetrieveEntityValidField(
414415
string $name,
415416
string $key,
@@ -457,11 +458,11 @@ public function testRetrieveEntityValidField(
457458
* @param string $type
458459
* @param string $scope
459460
* @param string $stepKey
460-
* @dataProvider entityDataProvider
461461
*
462462
* @return void
463463
* @throws TestReferenceException|TestFrameworkException
464464
*/
465+
#[DataProvider('entityDataProvider')]
465466
public function testRetrieveEntityInValidField(
466467
string $name,
467468
string $key,
@@ -557,20 +558,18 @@ public function mockCurlHandler(string $response, array $parserOutput): void
557558
$objectManagerMockInstance = $this->createMock(ObjectManager::class);
558559
$objectManagerMockInstance->expects($this->any())
559560
->method('create')
560-
->will(
561-
$this->returnCallback(
562-
function ($class, $arguments = []) use ($curlHandler, $objectManager, $dataProfileSchemaParser) {
563-
if ($class === CurlHandler::class) {
564-
return $curlHandler;
565-
}
566-
567-
if ($class === DataProfileSchemaParser::class) {
568-
return $dataProfileSchemaParser;
569-
}
570-
571-
return $objectManager->create($class, $arguments);
561+
->willReturnCallback(
562+
function ($class, $arguments = []) use ($curlHandler, $objectManager, $dataProfileSchemaParser) {
563+
if ($class === CurlHandler::class) {
564+
return $curlHandler;
572565
}
573-
)
566+
567+
if ($class === DataProfileSchemaParser::class) {
568+
return $dataProfileSchemaParser;
569+
}
570+
571+
return $objectManager->create($class, $arguments);
572+
}
574573
);
575574

576575
$objectManagerProperty = new ReflectionProperty(ObjectManager::class, 'instance');

dev/tests/unit/Magento/FunctionalTestFramework/Module/Util/ModuleUtilTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace tests\unit\Magento\FunctionalTestFramework\Module\Util;
1010

1111
use Magento\FunctionalTestingFramework\Module\Util\ModuleUtils;
12+
use PHPUnit\Framework\Attributes\DataProvider;
1213
use PHPUnit\Framework\TestCase;
1314

1415
class ModuleUtilTest extends TestCase
@@ -21,8 +22,8 @@ class ModuleUtilTest extends TestCase
2122
* @param string $removed
2223
*
2324
* @return void
24-
* @dataProvider inDataProvider
2525
*/
26+
#[DataProvider('inDataProvider')]
2627
public function testUtf8SafeControlCharacterTrim(string $input, string $output, $removed): void
2728
{
2829
$util = new ModuleUtils();

dev/tests/unit/Magento/FunctionalTestFramework/Page/Handlers/PageObjectHandlerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ private function mockPageObjectHandlerWithData(array $mockData): void
146146
$mockObjectManagerInstance = $this->createMock(ObjectManager::class);
147147
$mockObjectManagerInstance
148148
->method('get')
149-
->will(
150-
$this->returnCallback(
149+
->willReturnCallback(
151150
function (
152151
string $class,
153152
array $arguments = []
@@ -161,7 +160,6 @@ function (
161160

162161
return $objectManager->create($class, $arguments);
163162
}
164-
)
165163
);
166164

167165
$property = new ReflectionProperty(ObjectManager::class, 'instance');

dev/tests/unit/Magento/FunctionalTestFramework/Page/Handlers/SectionObjectHandlerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ private function mockSectionObjectHandlerWithData(array $mockData): void
131131
$mockObjectManagerInstance = $this->createMock(ObjectManager::class);
132132
$mockObjectManagerInstance
133133
->method('get')
134-
->will(
135-
$this->returnCallback(
134+
->willReturnCallback(
136135
function (
137136
string $class,
138137
array $arguments = []
@@ -146,7 +145,6 @@ function (
146145

147146
return $objectManager->create($class, $arguments);
148147
}
149-
)
150148
);
151149

152150
$property = new ReflectionProperty(ObjectManager::class, 'instance');

dev/tests/unit/Magento/FunctionalTestFramework/StaticCheck/DeprecatedEntityUsageCheckTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,7 @@ private function mockOperationHandlerWithData(array $mockData): void
309309
$mockObjectManagerInstance = $this->createMock(ObjectManager::class);
310310
$mockObjectManagerInstance
311311
->method('create')
312-
->will(
313-
$this->returnCallback(
312+
->willReturnCallback(
314313
function (
315314
string $class,
316315
array $arguments = []
@@ -324,7 +323,6 @@ function (
324323

325324
return $objectManager->create($class, $arguments);
326325
}
327-
)
328326
);
329327

330328
$property = new ReflectionProperty(ObjectManager::class, 'instance');

0 commit comments

Comments
 (0)