You are here

public function Framework_MockObjectTest::testObjectMethodCallWithArgumentCloningEnabled in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpunit/phpunit-mock-objects/tests/MockObjectTest.php \Framework_MockObjectTest::testObjectMethodCallWithArgumentCloningEnabled()

File

vendor/phpunit/phpunit-mock-objects/tests/MockObjectTest.php, line 465

Class

Framework_MockObjectTest
@since Class available since Release 3.0.0

Code

public function testObjectMethodCallWithArgumentCloningEnabled() {
  $expectedObject = new StdClass();
  $mock = $this
    ->getMockBuilder('SomeClass')
    ->setMethods(array(
    'doSomethingElse',
  ))
    ->enableArgumentCloning()
    ->getMock();
  $actualArguments = array();
  $mock
    ->expects($this
    ->any())
    ->method('doSomethingElse')
    ->will($this
    ->returnCallback(function () use (&$actualArguments) {
    $actualArguments = func_get_args();
  }));
  $mock
    ->doSomethingElse($expectedObject);
  $this
    ->assertEquals(1, count($actualArguments));
  $this
    ->assertEquals($expectedObject, $actualArguments[0]);
  $this
    ->assertNotSame($expectedObject, $actualArguments[0]);
}