diff --git a/.travis.yml b/.travis.yml index a207061..dd80848 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,10 @@ env: - PHPUNIT_VERSION=~6.2.0 - PHPUNIT_VERSION=~6.3.0 - PHPUNIT_VERSION=~6.4.0 + - PHPUNIT_VERSION=~6.5.0 php: + - 7.2 - 7.1 - 7.0 - hhvm diff --git a/autoload.php b/autoload.php new file mode 100644 index 0000000..fbac68f --- /dev/null +++ b/autoload.php @@ -0,0 +1,29 @@ +parameters); + $r = new \ReflectionObject($invocation); + $method = $r->hasMethod('getParameters'); + + if ($method) { + $params = $invocation->getParameters(); + } else { + $params = &$invocation->parameters; + } + + MockFunctionGenerator::removeDefaultArguments($params); + + if ($method) { + while (! $r->hasProperty('parameters')) { + $r = $r->getParentClass(); + } + $p = $r->getProperty('parameters'); + $p->setAccessible(true); + $p->setValue($invocation, $params); + } + return false; } diff --git a/classes/MockObjectProxy.php b/classes/MockObjectProxy.php index 4776822..0132be0 100644 --- a/classes/MockObjectProxy.php +++ b/classes/MockObjectProxy.php @@ -2,7 +2,8 @@ namespace phpmock\phpunit; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\Matcher\Invocation; +use PHPUnit\Framework\MockObject\MockObject; use phpmock\integration\MockDelegateFunctionBuilder; /** @@ -61,7 +62,7 @@ public function __phpunit_verify() return $this->mockObject->__phpunit_verify(); } - public function expects(\PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) + public function expects(Invocation $matcher) { return $this->mockObject->expects($matcher)->method(MockDelegateFunctionBuilder::METHOD); } diff --git a/classes/PHPMock.php b/classes/PHPMock.php index 3746ad2..a63ebfa 100644 --- a/classes/PHPMock.php +++ b/classes/PHPMock.php @@ -5,6 +5,7 @@ use phpmock\integration\MockDelegateFunctionBuilder; use phpmock\MockBuilder; use phpmock\Deactivatable; +use PHPUnit\Framework\MockObject\MockObject; /** * Adds building a function mock functionality into \PHPUnit\Framework\TestCase. @@ -42,7 +43,7 @@ trait PHPMock * This method exists in \PHPUnit\Framework\TestCase. * * @param string $className Name of the class to mock. - * @return \PHPUnit_Framework_MockObject_MockBuilder + * @return \PHPUnit\Framework\MockObject\MockBuilder * @see \PHPUnit\Framework\TestCase::getMockBuilder() * @internal */ @@ -67,7 +68,7 @@ abstract protected function getTestResultObject(); * @param string $namespace The function namespace. * @param string $name The function name. * - * @return \PHPUnit_Framework_MockObject_MockObject The PHPUnit mock. + * @return MockObject The PHPUnit mock. */ public function getFunctionMock($namespace, $name) { diff --git a/composer.json b/composer.json index 3739c14..b50f69c 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ } ], "autoload": { + "files": ["autoload.php"], "psr-4": {"phpmock\\phpunit\\": "classes/"} }, "require": { diff --git a/tests/MockObjectProxyTest.php b/tests/MockObjectProxyTest.php index d7de226..4bc4edc 100644 --- a/tests/MockObjectProxyTest.php +++ b/tests/MockObjectProxyTest.php @@ -2,7 +2,9 @@ namespace phpmock\phpunit; -use \PHPUnit_Framework_MockObject_Builder_InvocationMocker as InvocationMocker; +use PHPUnit\Framework\MockObject\Builder\InvocationMocker; +use PHPUnit\Framework\MockObject\Matcher\Invocation; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use phpmock\integration\MockDelegateFunctionBuilder; @@ -25,13 +27,13 @@ class MockObjectProxyTest extends TestCase */ public function testExpects() { - $matcher = $this->getMockBuilder(\PHPUnit_Framework_MockObject_Matcher_Invocation::class)->getMock(); + $matcher = $this->getMockBuilder(Invocation::class)->getMock(); $invocationMocker = $this->getMockBuilder(InvocationMocker::class)->disableOriginalConstructor()->getMock(); $invocationMocker->expects($this->once())->method("method") ->with(MockDelegateFunctionBuilder::METHOD)->willReturn($invocationMocker); - $prophecy = $this->prophesize(\PHPUnit_Framework_MockObject_MockObject::class); + $prophecy = $this->prophesize(MockObject::class); $prophecy->expects($matcher)->willReturn($invocationMocker); $mock = $prophecy->reveal(); @@ -53,7 +55,7 @@ public function testExpects() */ public function testHasMatcher() { - $prophecy = $this->prophesize(\PHPUnit_Framework_MockObject_MockObject::class); + $prophecy = $this->prophesize(MockObject::class); $prophecy->__phpunit_hasMatchers()->willReturn("foo"); $mock = $prophecy->reveal(); @@ -74,7 +76,7 @@ public function testHasMatcher() */ public function testProxiedMethods($method, array $arguments = [], $expected = "foo") { - $prophecy = $this->prophesize(\PHPUnit_Framework_MockObject_MockObject::class); + $prophecy = $this->prophesize(MockObject::class); call_user_func_array([$prophecy, $method], $arguments)->willReturn($expected); $mock = $prophecy->reveal();