Drupal investigation

nonexistent_class.phpt 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. --TEST--
  2. PHPUnit_Framework_MockObject_Generator::generate('NonExistentClass', array(), 'MockFoo', TRUE, TRUE)
  3. --FILE--
  4. <?php
  5. require __DIR__ . '/../../vendor/autoload.php';
  6. $generator = new PHPUnit_Framework_MockObject_Generator;
  7. $mock = $generator->generate(
  8. 'NonExistentClass',
  9. array(),
  10. 'MockFoo',
  11. TRUE,
  12. TRUE
  13. );
  14. print $mock['code'];
  15. ?>
  16. --EXPECTF--
  17. class NonExistentClass
  18. {
  19. }
  20. class MockFoo extends NonExistentClass implements PHPUnit_Framework_MockObject_MockObject
  21. {
  22. private $__phpunit_invocationMocker;
  23. private $__phpunit_originalObject;
  24. public function __clone()
  25. {
  26. $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
  27. }
  28. public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
  29. {
  30. return $this->__phpunit_getInvocationMocker()->expects($matcher);
  31. }
  32. public function method()
  33. {
  34. $any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
  35. $expects = $this->expects($any);
  36. return call_user_func_array(array($expects, 'method'), func_get_args());
  37. }
  38. public function __phpunit_setOriginalObject($originalObject)
  39. {
  40. $this->__phpunit_originalObject = $originalObject;
  41. }
  42. public function __phpunit_getInvocationMocker()
  43. {
  44. if ($this->__phpunit_invocationMocker === NULL) {
  45. $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
  46. }
  47. return $this->__phpunit_invocationMocker;
  48. }
  49. public function __phpunit_hasMatchers()
  50. {
  51. return $this->__phpunit_getInvocationMocker()->hasMatchers();
  52. }
  53. public function __phpunit_verify()
  54. {
  55. $this->__phpunit_getInvocationMocker()->verify();
  56. $this->__phpunit_invocationMocker = NULL;
  57. }
  58. }