You are here

public function Framework_MockObjectTest::testStubbedReturnValueMap in Zircon Profile 8

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

File

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

Class

Framework_MockObjectTest
@since Class available since Release 3.0.0

Code

public function testStubbedReturnValueMap() {
  $map = array(
    array(
      'a',
      'b',
      'c',
      'd',
    ),
    array(
      'e',
      'f',
      'g',
      'h',
    ),
  );
  $mock = $this
    ->getMock('AnInterface');
  $mock
    ->expects($this
    ->any())
    ->method('doSomething')
    ->will($this
    ->returnValueMap($map));
  $this
    ->assertEquals('d', $mock
    ->doSomething('a', 'b', 'c'));
  $this
    ->assertEquals('h', $mock
    ->doSomething('e', 'f', 'g'));
  $this
    ->assertEquals(null, $mock
    ->doSomething('foo', 'bar'));
  $mock = $this
    ->getMock('AnInterface');
  $mock
    ->expects($this
    ->any())
    ->method('doSomething')
    ->willReturnMap($map);
  $this
    ->assertEquals('d', $mock
    ->doSomething('a', 'b', 'c'));
  $this
    ->assertEquals('h', $mock
    ->doSomething('e', 'f', 'g'));
  $this
    ->assertEquals(null, $mock
    ->doSomething('foo', 'bar'));
}