nonexistent_class.phpt 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. private $__phpunit_configurable = [];
  25. public function __clone()
  26. {
  27. $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
  28. }
  29. public function expects(\PHPUnit\Framework\MockObject\Matcher\Invocation $matcher)
  30. {
  31. return $this->__phpunit_getInvocationMocker()->expects($matcher);
  32. }
  33. public function method()
  34. {
  35. $any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
  36. $expects = $this->expects($any);
  37. return call_user_func_array(array($expects, 'method'), func_get_args());
  38. }
  39. public function __phpunit_setOriginalObject($originalObject)
  40. {
  41. $this->__phpunit_originalObject = $originalObject;
  42. }
  43. public function __phpunit_getInvocationMocker()
  44. {
  45. if ($this->__phpunit_invocationMocker === null) {
  46. $this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
  47. }
  48. return $this->__phpunit_invocationMocker;
  49. }
  50. public function __phpunit_hasMatchers()
  51. {
  52. return $this->__phpunit_getInvocationMocker()->hasMatchers();
  53. }
  54. public function __phpunit_verify($unsetInvocationMocker = true)
  55. {
  56. $this->__phpunit_getInvocationMocker()->verify();
  57. if ($unsetInvocationMocker) {
  58. $this->__phpunit_invocationMocker = null;
  59. }
  60. }
  61. }