Skip to content

Commit d805fe2

Browse files
MCLOUD-13148: Added support for PHP8.4
1 parent 47cdba6 commit d805fe2

File tree

5 files changed

+76
-36
lines changed

5 files changed

+76
-36
lines changed

Test/Functional/Acceptance/AcceptanceCest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
namespace Magento\CloudComponents\Test\Functional\Acceptance;
99

10+
/**
11+
* Class AcceptanceCest
12+
*
13+
* This class provides acceptance tests for Magento Cloud components.
14+
*/
1015
abstract class AcceptanceCest
1116
{
1217
/**

Test/Unit/Model/UrlFinder/EntityTest.php

Lines changed: 65 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class EntityTest extends TestCase
4343
protected function setUp(): void
4444
{
4545
$this->urlFactoryMock = $this->createMock(UrlFactory::class);
46-
$this->urlFinderMock = $this->getMockForAbstractClass(UrlFinderInterface::class);
46+
$this->urlFinderMock = $this->createMock(UrlFinderInterface::class);
4747
$this->urlFixerMock = $this->createMock(UrlFixer::class);
4848
}
4949

@@ -68,55 +68,90 @@ public function testGet()
6868
->method('getId')
6969
->willReturn('store2');
7070

71-
$urlMock1 = $this->getMockForAbstractClass(UrlInterface::class);
72-
$urlMock1->expects($this->once())
73-
->method('getUrl')
74-
->with('/path1')
75-
->willReturn('http://site1.com/path1');
76-
$urlMock1->expects($this->once())
71+
$urlMock1 = $this->createMock(UrlInterface::class);
72+
$urlMock1
73+
->expects($this->any())
7774
->method('setScope')
7875
->with('store1')
7976
->willReturnSelf();
80-
$urlMock2 = $this->getMockForAbstractClass(UrlInterface::class);
81-
$urlMock2->expects($this->once())
77+
$urlMock1
78+
->expects($this->any())
79+
->method('getUrl')
80+
->with('/path1')
81+
->willReturn('http://site1.com/path1');
82+
83+
$urlMock2 = $this->createMock(UrlInterface::class);
84+
$urlMock2
85+
->expects($this->any())
8286
->method('getUrl')
8387
->with('/path2')
8488
->willReturn('http://site2.com/path2');
85-
$urlMock2->expects($this->once())
89+
$urlMock2
90+
->expects($this->any())
8691
->method('setScope')
8792
->with('store2')
8893
->willReturnSelf();
8994

9095
$urlRewriteMock1 = $this->createMock(UrlRewrite::class);
91-
$urlRewriteMock1->expects($this->once())
96+
$urlRewriteMock1
97+
->expects($this->once())
9298
->method('getRequestPath')
9399
->willReturn('/path1');
94100
$urlRewriteMock2 = $this->createMock(UrlRewrite::class);
95-
$urlRewriteMock2->expects($this->once())
101+
$urlRewriteMock2
102+
->expects($this->once())
96103
->method('getRequestPath')
97104
->willReturn('/path2');
98105

99-
$this->urlFactoryMock->expects($this->exactly(2))
106+
$this->urlFactoryMock
107+
->expects($this->exactly(2))
100108
->method('create')
101-
->willReturnOnConsecutiveCalls($urlMock1, $urlMock2);
102-
$this->urlFinderMock->expects($this->exactly(2))
109+
->willReturnCallback(function () use ($urlMock1, $urlMock2) {
110+
static $callCount = 0;
111+
$callCount++;
112+
113+
if ($callCount === 1) {
114+
return $urlMock1;
115+
}
116+
117+
return $urlMock2;
118+
});
119+
120+
$this->urlFinderMock
121+
->expects($this->exactly(2))
103122
->method('findAllByData')
104-
->withConsecutive(
105-
[['store_id' => 'store1', 'entity_type' => 'category']],
106-
[['store_id' => 'store2', 'entity_type' => 'category']]
107-
)
108-
->willReturnOnConsecutiveCalls(
109-
[$urlRewriteMock1],
110-
[$urlRewriteMock2]
111-
);
112-
113-
$this->urlFixerMock->expects($this->exactly(2))
123+
->willReturnCallback(function ($data) use ($urlRewriteMock1, $urlRewriteMock2) {
124+
$expected1 = ['store_id' => 'store1', 'entity_type' => 'category'];
125+
$expected2 = ['store_id' => 'store2', 'entity_type' => 'category'];
126+
127+
if (array_intersect_assoc($expected1, $data) == $expected1) {
128+
return [$urlRewriteMock1];
129+
}
130+
131+
if (array_intersect_assoc($expected2, $data) == $expected2) {
132+
return [$urlRewriteMock2];
133+
}
134+
135+
return [];
136+
});
137+
138+
$this->urlFixerMock
139+
->expects($this->exactly(2))
114140
->method('run')
115-
->withConsecutive(
116-
[$storeMock1, 'http://site1.com/path1'],
117-
[$storeMock2, 'http://site2.com/path2']
118-
)
119-
->willReturnOnConsecutiveCalls('http://site1.com/fixed/path1', 'http://site2.com/fixed/path2');
141+
->willReturnCallback(function ($store, $url) use ($storeMock1, $storeMock2) {
142+
static $callCount = 0;
143+
$callCount++;
144+
145+
if ($callCount === 1 && $store === $storeMock1 && $url === '/path1') {
146+
return 'http://site1.com/fixed/path1';
147+
}
148+
149+
if ($callCount === 2 && $store === $storeMock2 && $url === '/path2') {
150+
return 'http://site2.com/fixed/path2';
151+
}
152+
153+
return '';
154+
});
120155

121156
$entity = $this->createEntity('category', [$storeMock1, $storeMock2]);
122157

Test/Unit/Model/UrlFixerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testRunWithConfigRewrites(
7373
/**
7474
* @return array
7575
*/
76-
public function runDataProvider(): array
76+
public static function runDataProvider(): array
7777
{
7878
return [
7979
'rewrites enabled, url without "magento" part' => [

Test/Unit/phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/10.5/phpunit.xsd"
55
colors="true"
66
columns="max"
77
bootstrap="../../vendor/autoload.php"

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento/magento-cloud-components",
33
"description": "Cloud Components Module for Magento 2.x",
44
"type": "magento2-module",
5-
"version": "1.0.13",
5+
"version": "1.0.14",
66
"require": {
77
"php": "^8.0",
88
"ext-json": "*",
@@ -22,9 +22,9 @@
2222
"codeception/module-rest": "^3.0",
2323
"consolidation/robo": "^3.0",
2424
"phpmd/phpmd": "@stable",
25-
"phpstan/phpstan": "~1.2.0",
26-
"phpunit/phpunit": "^9.5",
27-
"squizlabs/php_codesniffer": "^3.0"
25+
"phpstan/phpstan": "~1.2.0 || ^2.0",
26+
"phpunit/phpunit": "^9.5 || ^10.5",
27+
"squizlabs/php_codesniffer": "^3.7"
2828
},
2929
"config": {
3030
"sort-packages": true

0 commit comments

Comments
 (0)