Skip to content

Commit e2eb79d

Browse files
committed
Updated phpunit from 9.6.x to 11.2.x, with deps:
- Removing doctrine/instantiator (2.0.0) - Removing sebastian/resource-operations (3.0.4) - Upgrading phpunit/php-code-coverage (9.2.31 => 11.0.5) - Upgrading phpunit/php-file-iterator (3.0.6 => 5.0.1) - Upgrading phpunit/php-invoker (3.1.1 => 5.0.1) - Upgrading phpunit/php-text-template (2.0.4 => 4.0.1) - Upgrading phpunit/php-timer (5.0.3 => 7.0.1) - Upgrading phpunit/phpunit (9.6.19 => 11.2.6) - Upgrading sebastian/cli-parser (1.0.2 => 3.0.2) - Upgrading sebastian/code-unit (1.0.8 => 3.0.1) - Upgrading sebastian/code-unit-reverse-lookup (2.0.3 => 4.0.1) - Upgrading sebastian/comparator (4.0.8 => 6.0.1) - Upgrading sebastian/complexity (2.0.3 => 4.0.1) - Upgrading sebastian/diff (4.0.6 => 6.0.2) - Upgrading sebastian/environment (5.1.5 => 7.2.0) - Upgrading sebastian/exporter (4.0.6 => 6.1.3) - Upgrading sebastian/global-state (5.0.7 => 7.0.2) - Upgrading sebastian/lines-of-code (1.0.4 => 3.0.1) - Upgrading sebastian/object-enumerator (4.0.4 => 6.0.1) - Upgrading sebastian/object-reflector (2.0.4 => 4.0.1) - Upgrading sebastian/recursion-context (4.0.5 => 6.0.2) - Upgrading sebastian/type (3.2.1 => 5.0.1) - Upgrading sebastian/version (3.0.2 => 5.0.1)
1 parent 417fea4 commit e2eb79d

File tree

7 files changed

+283
-381
lines changed

7 files changed

+283
-381
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ check: checkstyle checkquality test
1212
checkstyle:
1313
vendor-bin/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run --diff --stop-on-violation --allow-risky=yes
1414
vendor-bin/phpcs/vendor/bin/phpcs -s --standard=Magento2 --exclude=Magento2.Security.InsecureFunction,Magento2.Commenting.ClassPropertyPHPDocFormatting,Magento2.Annotation.MethodAnnotationStructure,Magento2.Annotation.MethodArguments,PSR12.Properties.ConstantVisibility,PSR2.Classes.ClassDeclaration,Squiz.WhiteSpace.ScopeClosingBrace,Magento2.Legacy.EscapeMethodsOnBlockClass --ignore=./vendor/,./vendor-bin/ .
15-
vendor-bin/phpcs/vendor/bin/phpcs -s --standard=PHPCompatibility --runtime-set testVersion 7.1- --ignore=./vendor/,./vendor-bin/ .
15+
vendor-bin/phpcs/vendor/bin/phpcs -s --standard=PHPCompatibility --runtime-set testVersion 7.1- --ignore=./vendor/,./vendor-bin/,./Test/ .
16+
vendor-bin/phpcs/vendor/bin/phpcs -s --standard=PHPCompatibility --runtime-set testVersion 8.0- ./Test/
1617
vendor/bin/composer normalize --dry-run
1718

1819
.PHONY: checkquality

Test/Checker/Catalog/Product/UrlKey/DuplicateUrlKeyTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
1414
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
1515
use Magento\Framework\DataObject;
16+
use PHPUnit\Framework\Attributes\DataProvider;
1617
use PHPUnit\Framework\TestCase;
1718

1819
class DuplicateUrlKeyTest extends TestCase
1920
{
2021
/**
21-
* @dataProvider duplicatedProductUrlKeyValuesDataProvider
22-
*
2322
* @param array<array<string, mixed>> $dbData
2423
* @param array<array<string, mixed>> $expectedResults
2524
*/
25+
#[DataProvider('duplicatedProductUrlKeyValuesDataProvider')]
2626
public function testDuplicatedProductUrlKeyValues(array $dbData, array $expectedResults): void
2727
{
2828
$dbData = array_map(function ($productData) {
@@ -52,7 +52,7 @@ function ($productsData) {
5252
->getMock();
5353
$productCollectionMock->expects($this->any())
5454
->method('getIterator')
55-
->will($this->returnValue(new \ArrayIterator($productsData)));
55+
->willReturn(new \ArrayIterator($productsData));
5656

5757
$productCollectionMock->expects($this->once())
5858
->method('setStoreId')
@@ -93,7 +93,7 @@ function ($productsData) {
9393

9494
$productCollectionFactoryMock->expects($this->exactly(count($storeIds)))
9595
->method('create')
96-
->will($this->onConsecutiveCalls(...$collectionsPerStoreId)); // ... turns array into seperate arguments
96+
->willReturn(...$collectionsPerStoreId); // ... turns array into seperate arguments
9797

9898
$attributeScopeOverriddenValueMock = $this
9999
->getMockBuilder(AttributeScopeOverriddenValue::class)
@@ -134,7 +134,7 @@ function ($productsData) {
134134
/**
135135
* @return array<array<array<array<string, mixed>>>>
136136
*/
137-
public function duplicatedProductUrlKeyValuesDataProvider(): array
137+
public static function duplicatedProductUrlKeyValuesDataProvider(): array
138138
{
139139
return [
140140
// 0. two products having different url key, is ok!

Test/Storage/CacheStorageTest.php

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,27 @@ public function testUpdatingExisting(): void
6060
->disableOriginalConstructor()
6161
->getMock();
6262

63-
$cacheMock->expects($this->exactly(2))
63+
$matcher = $this->exactly(2);
64+
$cacheMock->expects($matcher)
6465
->method('save')
65-
->withConsecutive(
66-
[$this->jsonEncode($existingData)],
67-
[$this->jsonEncode($expectedData)]
68-
)
69-
->willReturn(true);
66+
// replacement for withConsecutive,
67+
// using https://github.com/sebastianbergmann/phpunit/issues/4026#issuecomment-1556763479
68+
->willReturnCallback(function (string $param) use ($matcher, $existingData, $expectedData) {
69+
match ($matcher->numberOfInvocations()) {
70+
1 => $this->assertEquals($param, $this->jsonEncode($existingData)),
71+
2 => $this->assertEquals($param, $this->jsonEncode($expectedData)),
72+
default => throw new \LogicException('unexpected amount of calls'),
73+
};
74+
75+
return true;
76+
});
7077

7178
$cacheMock->expects($this->exactly(2))
7279
->method('load')
73-
->will($this->onConsecutiveCalls(
80+
->willReturn(
7481
$this->jsonEncode($existingData),
75-
$this->jsonEncode($expectedData)
76-
));
82+
$this->jsonEncode($expectedData),
83+
);
7784

7885
$cacheStorage = new CacheStorage($cacheMock);
7986
$cacheStorage->write($identifier, $existingData);
@@ -97,13 +104,20 @@ public function testClear(): void
97104
->disableOriginalConstructor()
98105
->getMock();
99106

100-
$cacheMock->expects($this->exactly(2))
107+
$matcher = $this->exactly(2);
108+
$cacheMock->expects($matcher)
101109
->method('save')
102-
->withConsecutive(
103-
[$this->jsonEncode($existingData)],
104-
[$this->jsonEncode($expectedData)]
105-
)
106-
->willReturn(true);
110+
// replacement for withConsecutive,
111+
// using https://github.com/sebastianbergmann/phpunit/issues/4026#issuecomment-1556763479
112+
->willReturnCallback(function (string $param) use ($matcher, $existingData, $expectedData) {
113+
match ($matcher->numberOfInvocations()) {
114+
1 => $this->assertEquals($param, $this->jsonEncode($existingData)),
115+
2 => $this->assertEquals($param, $this->jsonEncode($expectedData)),
116+
default => throw new \LogicException('unexpected amount of calls'),
117+
};
118+
119+
return true;
120+
});
107121

108122
$cacheMock->expects($this->exactly(1))
109123
->method('load')

Test/phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.5/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
44
colors="true"
55
columns="max"
66
bootstrap="./bootstrap.php"

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"bamarni/composer-bin-plugin": "^1.7",
2727
"ergebnis/composer-normalize": "^2.17",
2828
"mikey179/vfsstream": "^1.6",
29-
"phpunit/phpunit": "^9.0"
29+
"phpunit/phpunit": "^11.2"
3030
},
3131
"repositories": [
3232
{

0 commit comments

Comments
 (0)