Skip to content

Commit

Permalink
Replace usage of deprecated getMock()
Browse files Browse the repository at this point in the history
PHPUnit-5.4 marked PHPUnit_Framework_TestCase::getMock() as deprecated.
It suggests to replace that usage with either createMock() or
getMockBuilder(). createMock() is only available since PHPUnit-5.4. This
commit replaces the usage of getMock() with getMockBuilder() as it is
also available in older PHPUnit versions.
  • Loading branch information
malkusch committed Aug 5, 2016
1 parent 0ea5ece commit 0891cb8
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/MockObjectProxyTest.php
Expand Up @@ -16,30 +16,30 @@
*/
class MockObjectProxyTest extends \PHPUnit_Framework_TestCase
{

/**
* Tests expects()
*
* @test
*/
public function testExpects()
{
$matcher = $this->getMock(\PHPUnit_Framework_MockObject_Matcher_Invocation::class);
$invocationMocker = $this->getMock(InvocationMocker::class, [], [], '', false);
$matcher = $this->getMockBuilder(\PHPUnit_Framework_MockObject_Matcher_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->expects($matcher)->willReturn($invocationMocker);
$mock = $prophecy->reveal();

$proxy = new MockObjectProxy($mock);

$result = $proxy->expects($matcher);
$this->assertEquals($invocationMocker, $result);
}

/**
* Tests delegation of __phpunit_hasMatchers().
*
Expand All @@ -55,13 +55,13 @@ public function testHasMatcher()
$prophecy = $this->prophesize(\PHPUnit_Framework_MockObject_MockObject::class);
$prophecy->__phpunit_hasMatchers()->willReturn("foo");
$mock = $prophecy->reveal();

$proxy = new MockObjectProxy($mock);

$result = $proxy->__phpunit_hasMatchers();
$this->assertEquals("foo", $result);
}

/**
* Tests calling the proxy forwards the call to the subject.
*
Expand All @@ -76,9 +76,9 @@ public function testProxiedMethods($method, array $arguments = [], $expected = "
$prophecy = $this->prophesize(\PHPUnit_Framework_MockObject_MockObject::class);
call_user_func_array([$prophecy, $method], $arguments)->willReturn($expected);
$mock = $prophecy->reveal();

$proxy = new MockObjectProxy($mock);

$result = call_user_func_array([$proxy, $method], $arguments);
$this->assertEquals($expected, $result);
}
Expand Down

0 comments on commit 0891cb8

Please sign in to comment.