Skip to content

Commit 239b259

Browse files
authored
Merge pull request #12 from run-as-root/feature/update-unit-tests
Update Unit tests to make them compatible with phpunit 10
2 parents 5939240 + 7c18dbb commit 239b259

File tree

4 files changed

+46
-36
lines changed

4 files changed

+46
-36
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
vendor/
55
composer.lock
66
.phpunit.result.cache
7+
.phpunit.cache/

lib/Test/Unit/Map/ProxiedConstructArgsToDiConfigMapperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function test_map(array $diConfig, string $instanceClassName, array $prox
2727
$this->assertEquals($expected, $result);
2828
}
2929

30-
public function mapDataProvider(): array
30+
public static function mapDataProvider(): array
3131
{
3232
return [
3333
'case1' => [
@@ -108,4 +108,4 @@ public function mapDataProvider(): array
108108

109109
];
110110
}
111-
}
111+
}

lib/Test/Unit/Service/GetProxiedConstructArgsConfigServiceTest.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,17 @@ public function test_get(): void
3131

3232
$this->proxyValidator->expects($this->exactly(2))
3333
->method('validate')
34-
->withConsecutive(['Some\Class'], ['Some\OtherClass'])
34+
->willReturnCallback(function () use (&$i) {
35+
switch ($i) {
36+
case 0:
37+
return ['Some\Class'];
38+
case 1:
39+
return ['Some\OtherClass'];
40+
}
41+
$i++;
42+
43+
return [];
44+
})
3545
->willReturnOnConsecutiveCalls(true, false);
3646

3747
$this->assertEquals(
@@ -56,7 +66,17 @@ public function test_get_with_no_eligible_classes(): void
5666

5767
$this->proxyValidator->expects($this->exactly(2))
5868
->method('validate')
59-
->withConsecutive(['Some\Class'], ['Some\OtherClass'])
69+
->willReturnCallback(function () use (&$i) {
70+
switch ($i) {
71+
case 0:
72+
return ['Some\Class'];
73+
case 1:
74+
return ['Some\OtherClass'];
75+
}
76+
$i++;
77+
78+
return [];
79+
})
6080
->willThrowException(new ClassIsNotEligibleForProxyException());
6181

6282
$this->assertEquals([], $this->sut->get($constructConfig));
@@ -66,4 +86,4 @@ public function testGetWithNoConstructConfig(): void
6686
{
6787
$this->assertEquals([], $this->sut->get([]));
6888
}
69-
}
89+
}

phpunit.xml

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit bootstrap = "vendor/autoload.php"
4-
backupGlobals = "false"
5-
backupStaticAttributes = "false"
6-
colors = "true"
7-
convertErrorsToExceptions = "true"
8-
convertNoticesToExceptions = "true"
9-
convertWarningsToExceptions = "true"
10-
processIsolation = "false"
11-
stopOnFailure = "false">
12-
13-
<testsuites>
14-
<testsuite name="run-as-root/magento-cli-auto-proxy">
15-
<directory>lib/Test/Unit</directory>
16-
</testsuite>
17-
</testsuites>
18-
19-
<coverage cacheDirectory=".phpunit.cache/code-coverage" processUncoveredFiles="true">
20-
<include>
21-
<directory suffix=".php">lib</directory>
22-
</include>
23-
<report>
24-
<clover outputFile="clover.xml" />
25-
</report>
26-
</coverage>
27-
28-
<php>
29-
<env name="APP_ENV" value="testing"/>
30-
</php>
31-
32-
</phpunit>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<testsuites>
4+
<testsuite name="run-as-root/magento-cli-auto-proxy">
5+
<directory>lib/Test/Unit</directory>
6+
</testsuite>
7+
</testsuites>
8+
<coverage>
9+
<report>
10+
<clover outputFile="clover.xml"/>
11+
</report>
12+
</coverage>
13+
<php>
14+
<env name="APP_ENV" value="testing"/>
15+
</php>
16+
<source>
17+
<include>
18+
<directory suffix=".php">lib</directory>
19+
</include>
20+
</source>
21+
</phpunit>

0 commit comments

Comments
 (0)