Drupal investigation

ConsecutiveParametersTest.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. class Framework_MockObject_Matcher_ConsecutiveParametersTest extends PHPUnit_Framework_TestCase
  3. {
  4. public function testIntegration()
  5. {
  6. $mock = $this->getMock('stdClass', array('foo'));
  7. $mock
  8. ->expects($this->any())
  9. ->method('foo')
  10. ->withConsecutive(
  11. array('bar'),
  12. array(21, 42)
  13. );
  14. $mock->foo('bar');
  15. $mock->foo(21, 42);
  16. }
  17. public function testIntegrationWithLessAssertionsThenMethodCalls()
  18. {
  19. $mock = $this->getMock('stdClass', array('foo'));
  20. $mock
  21. ->expects($this->any())
  22. ->method('foo')
  23. ->withConsecutive(
  24. array('bar')
  25. );
  26. $mock->foo('bar');
  27. $mock->foo(21, 42);
  28. }
  29. public function testIntegrationExpectingException()
  30. {
  31. $mock = $this->getMock('stdClass', array('foo'));
  32. $mock
  33. ->expects($this->any())
  34. ->method('foo')
  35. ->withConsecutive(
  36. array('bar'),
  37. array(21, 42)
  38. );
  39. $mock->foo('bar');
  40. $this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
  41. $mock->foo('invalid');
  42. }
  43. }