ConsecutiveParametersTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. }