Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Unit tests to make them compatible with phpunit 10 #12

Merged
merged 1 commit into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
vendor/
composer.lock
.phpunit.result.cache
.phpunit.cache/
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function test_map(array $diConfig, string $instanceClassName, array $prox
$this->assertEquals($expected, $result);
}

public function mapDataProvider(): array
public static function mapDataProvider(): array
{
return [
'case1' => [
Expand Down Expand Up @@ -108,4 +108,4 @@ public function mapDataProvider(): array

];
}
}
}
26 changes: 23 additions & 3 deletions lib/Test/Unit/Service/GetProxiedConstructArgsConfigServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ public function test_get(): void

$this->proxyValidator->expects($this->exactly(2))
->method('validate')
->withConsecutive(['Some\Class'], ['Some\OtherClass'])
->willReturnCallback(function () use (&$i) {
switch ($i) {
case 0:
return ['Some\Class'];
case 1:
return ['Some\OtherClass'];
}
$i++;

return [];
})
->willReturnOnConsecutiveCalls(true, false);

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

$this->proxyValidator->expects($this->exactly(2))
->method('validate')
->withConsecutive(['Some\Class'], ['Some\OtherClass'])
->willReturnCallback(function () use (&$i) {
switch ($i) {
case 0:
return ['Some\Class'];
case 1:
return ['Some\OtherClass'];
}
$i++;

return [];
})
->willThrowException(new ClassIsNotEligibleForProxyException());

$this->assertEquals([], $this->sut->get($constructConfig));
Expand All @@ -66,4 +86,4 @@ public function testGetWithNoConstructConfig(): void
{
$this->assertEquals([], $this->sut->get([]));
}
}
}
51 changes: 20 additions & 31 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap = "vendor/autoload.php"
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false">

<testsuites>
<testsuite name="run-as-root/magento-cli-auto-proxy">
<directory>lib/Test/Unit</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage" processUncoveredFiles="true">
<include>
<directory suffix=".php">lib</directory>
</include>
<report>
<clover outputFile="clover.xml" />
</report>
</coverage>

<php>
<env name="APP_ENV" value="testing"/>
</php>

</phpunit>
<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">
<testsuites>
<testsuite name="run-as-root/magento-cli-auto-proxy">
<directory>lib/Test/Unit</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<clover outputFile="clover.xml"/>
</report>
</coverage>
<php>
<env name="APP_ENV" value="testing"/>
</php>
<source>
<include>
<directory suffix=".php">lib</directory>
</include>
</source>
</phpunit>