From 7c18dbbe1edb953954daefa7e7cb39206a75ccb2 Mon Sep 17 00:00:00 2001 From: Vlad Podorozhnyi Date: Sun, 6 Aug 2023 18:28:05 +0200 Subject: [PATCH] Update Unit tests to make them compatible with phpunit 10 --- .gitignore | 1 + ...oxiedConstructArgsToDiConfigMapperTest.php | 4 +- ...tProxiedConstructArgsConfigServiceTest.php | 26 ++++++++-- phpunit.xml | 51 ++++++++----------- 4 files changed, 46 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index b2aa5a7..23e9657 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ vendor/ composer.lock .phpunit.result.cache +.phpunit.cache/ diff --git a/lib/Test/Unit/Map/ProxiedConstructArgsToDiConfigMapperTest.php b/lib/Test/Unit/Map/ProxiedConstructArgsToDiConfigMapperTest.php index 542b1a0..85f7edb 100644 --- a/lib/Test/Unit/Map/ProxiedConstructArgsToDiConfigMapperTest.php +++ b/lib/Test/Unit/Map/ProxiedConstructArgsToDiConfigMapperTest.php @@ -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' => [ @@ -108,4 +108,4 @@ public function mapDataProvider(): array ]; } -} \ No newline at end of file +} diff --git a/lib/Test/Unit/Service/GetProxiedConstructArgsConfigServiceTest.php b/lib/Test/Unit/Service/GetProxiedConstructArgsConfigServiceTest.php index 7798770..2899ff9 100644 --- a/lib/Test/Unit/Service/GetProxiedConstructArgsConfigServiceTest.php +++ b/lib/Test/Unit/Service/GetProxiedConstructArgsConfigServiceTest.php @@ -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( @@ -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)); @@ -66,4 +86,4 @@ public function testGetWithNoConstructConfig(): void { $this->assertEquals([], $this->sut->get([])); } -} \ No newline at end of file +} diff --git a/phpunit.xml b/phpunit.xml index b979121..2cb84cd 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,32 +1,21 @@ - - - - - - lib/Test/Unit - - - - - - lib - - - - - - - - - - - \ No newline at end of file + + + + lib/Test/Unit + + + + + + + + + + + + + lib + + +