diff --git a/.travis.yml b/.travis.yml index f0d9d8e..0f53079 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,39 +8,44 @@ cache: env: - PHPUNIT_VERSION=dev-master - - PHPUNIT_VERSION=~6.0.0 - - PHPUNIT_VERSION=~6.1.0 - - PHPUNIT_VERSION=~6.2.0 - - PHPUNIT_VERSION=~6.3.0 - - PHPUNIT_VERSION=~6.4.0 - - PHPUNIT_VERSION=~6.5.0 - - PHPUNIT_VERSION=~7.0.0 - - PHPUNIT_VERSION=~7.1.0 - - 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 + - PHPUNIT_VERSION=~8.2.0 - PHPUNIT_VERSION=~8.1.0 + - PHPUNIT_VERSION=~8.0.0 + - PHPUNIT_VERSION=~7.5.0 + - PHPUNIT_VERSION=~7.4.0 + - PHPUNIT_VERSION=~7.3.0 + - PHPUNIT_VERSION=~7.2.0 + - PHPUNIT_VERSION=~7.1.0 + - PHPUNIT_VERSION=~7.0.0 + - PHPUNIT_VERSION=~6.5.0 + - PHPUNIT_VERSION=~6.4.0 + - PHPUNIT_VERSION=~6.3.0 + - PHPUNIT_VERSION=~6.2.0 + - PHPUNIT_VERSION=~6.1.0 + - PHPUNIT_VERSION=~6.0.0 php: + - 7.4snapshot - 7.3 - 7.2 - 7.1 - 7 - - hhvm matrix: fast_finish: true exclude: - php: 7.1 env: PHPUNIT_VERSION=dev-master + - php: 7.1 + env: PHPUNIT_VERSION=~8.2.0 - php: 7.1 env: PHPUNIT_VERSION=~8.1.0 - php: 7.1 env: PHPUNIT_VERSION=~8.0.0 - php: 7 env: PHPUNIT_VERSION=dev-master + - php: 7 + env: PHPUNIT_VERSION=~8.2.0 - php: 7 env: PHPUNIT_VERSION=~8.1.0 - php: 7 @@ -58,7 +63,7 @@ matrix: - php: 7 env: PHPUNIT_VERSION=~7.0.0 allow_failures: - - php: hhvm + - php: 7.4snapshot - env: PHPUNIT_VERSION=dev-master install: diff --git a/autoload.php b/autoload.php index 9de6a88..5eb1a7e 100644 --- a/autoload.php +++ b/autoload.php @@ -7,7 +7,9 @@ class_alias( ); } -if (! interface_exists(\PHPUnit\Framework\MockObject\Invocation::class)) { +if (! interface_exists(\PHPUnit\Framework\MockObject\Invocation::class) + && interface_exists(\PHPUnit_Framework_MockObject_Invocation::class) +) { class_alias( \PHPUnit_Framework_MockObject_Invocation::class, \PHPUnit\Framework\MockObject\Invocation::class diff --git a/classes/DefaultArgumentRemoverReturnTypes.php b/classes/DefaultArgumentRemoverReturnTypes.php index 1a8adf5..bfdadfe 100644 --- a/classes/DefaultArgumentRemoverReturnTypes.php +++ b/classes/DefaultArgumentRemoverReturnTypes.php @@ -29,8 +29,15 @@ public function invoked(Invocation $invocation) */ public function matches(Invocation $invocation) : bool { - if ($invocation instanceof Invocation\StaticInvocation) { - $this->removeDefaultArguments($invocation); + $iClass = class_exists(Invocation::class); + + if ($invocation instanceof Invocation\StaticInvocation + || $iClass + ) { + $this->removeDefaultArguments( + $invocation, + $iClass ? Invocation::class : Invocation\StaticInvocation::class + ); } else { MockFunctionGenerator::removeDefaultArguments($invocation->parameters); } @@ -64,12 +71,12 @@ public function toString() : string * * @SuppressWarnings(PHPMD) */ - private function removeDefaultArguments(Invocation\StaticInvocation $invocation) + private function removeDefaultArguments(Invocation $invocation, string $class) { $remover = function () { MockFunctionGenerator::removeDefaultArguments($this->parameters); }; - $remover->bindTo($invocation, Invocation\StaticInvocation::class)(); + $remover->bindTo($invocation, $class)(); } } diff --git a/tests/MockObjectProxyTest.php b/tests/MockObjectProxyTest.php index 317b763..244ab67 100644 --- a/tests/MockObjectProxyTest.php +++ b/tests/MockObjectProxyTest.php @@ -2,13 +2,15 @@ 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; +use PHPUnit\Framework\MockObject\ConfigurableMethod; use PHPUnit\Framework\MockObject\Matcher\Invocation; +use PHPUnit\Framework\MockObject\Matcher\MethodName; use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub\MatcherCollection; +use PHPUnit\Framework\TestCase; +use SebastianBergmann\Type\Type; /** * Tests MockObjectProxyTest. @@ -31,10 +33,17 @@ public function testExpects() { $matcher = $this->getMockBuilder(Invocation::class)->getMock(); + $methods = class_exists(ConfigurableMethod::class) + ? new ConfigurableMethod( + MockDelegateFunctionBuilder::METHOD, + $this->prophesize(Type::class)->reveal() + ) + : [MockDelegateFunctionBuilder::METHOD]; + $invocationMocker = new InvocationMocker( $this->prophesize(MatcherCollection::class)->reveal(), $this->prophesize(Invocation::class)->reveal(), - [MockDelegateFunctionBuilder::METHOD] + $methods ); $prophecy = $this->prophesize(MockObject::class);