You are here

public function Framework_MockObjectTest::testWithAnythingInsteadOfWithAnyParameters in Zircon Profile 8

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

@ticket 199

File

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

Class

Framework_MockObjectTest
@since Class available since Release 3.0.0

Code

public function testWithAnythingInsteadOfWithAnyParameters() {
  $mock = $this
    ->getMock('SomeClass', array(
    'right',
  ), array(), '', true, true, true);
  $mock
    ->expects($this
    ->once())
    ->method('right')
    ->with($this
    ->anything());
  try {
    $mock
      ->right();
    $this
      ->fail('Expected exception');
  } catch (PHPUnit_Framework_ExpectationFailedException $e) {
    $this
      ->assertSame("Expectation failed for method name is equal to <string:right> when invoked 1 time(s)\n" . "Parameter count for invocation SomeClass::right() is too low.\n" . "To allow 0 or more parameters with any value, omit ->with() or use ->withAnyParameters() instead.", $e
      ->getMessage());
  }
  $this
    ->resetMockObjects();
}