diff --git a/.travis.yml b/.travis.yml index c8b6287..4da042a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,8 @@ env: - PHPUNIT_VERSION=~7.2.0 - PHPUNIT_VERSION=~7.3.0 - PHPUNIT_VERSION=~7.4.0 + - PHPUNIT_VERSION=~7.5.0 + - PHPUNIT_VERSION=~8.0.0 php: - 7.3 @@ -30,8 +32,16 @@ php: matrix: fast_finish: true exclude: + - php: 7.1 + env: PHPUNIT_VERSION=dev-master + - php: 7.1 + env: PHPUNIT_VERSION=~8.0.0 - php: 7 env: PHPUNIT_VERSION=dev-master + - php: 7 + env: PHPUNIT_VERSION=~8.0.0 + - php: 7 + env: PHPUNIT_VERSION=~7.5.0 - php: 7 env: PHPUNIT_VERSION=~7.4.0 - php: 7 diff --git a/autoload.php b/autoload.php index 06fc33b..67c8e93 100644 --- a/autoload.php +++ b/autoload.php @@ -28,6 +28,20 @@ class_alias( ); } +if (! class_exists(\PHPUnit\Framework\MockObject\Matcher\MethodName::class)) { + class_alias( + \PHPUnit_Framework_MockObject_Matcher_MethodName::class, + \PHPUnit\Framework\MockObject\Matcher\MethodName::class + ); +} + +if (! interface_exists(\PHPUnit\Framework\MockObject\Stub\MatcherCollection::class)) { + class_alias( + \PHPUnit_Framework_MockObject_Stub_MatcherCollection::class, + \PHPUnit\Framework\MockObject\Stub\MatcherCollection::class + ); +} + if (! class_exists(\PHPUnit\Framework\BaseTestListener::class)) { include __DIR__ . '/compatibility/BaseTestListener.php'; class_alias( diff --git a/composer.json b/composer.json index 5a93b9d..cfc2c6a 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7", - "phpunit/phpunit": "^6 || ^7", + "phpunit/phpunit": "^6 || ^7 || ^8", "php-mock/php-mock-integration": "^2" }, "archive": { diff --git a/tests/MockObjectProxyTest.php b/tests/MockObjectProxyTest.php index 5587d0f..8f28d1c 100644 --- a/tests/MockObjectProxyTest.php +++ b/tests/MockObjectProxyTest.php @@ -2,6 +2,8 @@ namespace phpmock\phpunit; +use PHPUnit\Framework\MockObject\Matcher\MethodName; +use PHPUnit\Framework\MockObject\Stub\MatcherCollection; use PHPUnit\Framework\TestCase; use phpmock\integration\MockDelegateFunctionBuilder; use PHPUnit\Framework\MockObject\Builder\InvocationMocker; @@ -29,9 +31,11 @@ public function testExpects() { $matcher = $this->getMockBuilder(Invocation::class)->getMock(); - $invocationMocker = $this->getMockBuilder(InvocationMocker::class)->disableOriginalConstructor()->getMock(); - $invocationMocker->expects($this->once())->method("method") - ->with(MockDelegateFunctionBuilder::METHOD)->willReturn($invocationMocker); + $invocationMocker = new InvocationMocker( + $this->prophesize(MatcherCollection::class)->reveal(), + $this->prophesize(Invocation::class)->reveal(), + [MockDelegateFunctionBuilder::METHOD] + ); $prophecy = $this->prophesize(MockObject::class); $prophecy->expects($matcher)->willReturn($invocationMocker); @@ -41,6 +45,12 @@ public function testExpects() $result = $proxy->expects($matcher); $this->assertEquals($invocationMocker, $result); + + $this->assertSame( + (new MethodName(MockDelegateFunctionBuilder::METHOD))->toString(), + ($invocationMocker->getMatcher()->methodNameMatcher + ?? $invocationMocker->getMatcher()->getMethodNameMatcher())->toString() + ); } /**