1--TEST-- 2PHPUnit_Framework_MockObject_Generator::generate('Foo', null, 'ProxyFoo', true, true, true, true) 3--FILE-- 4<?php 5class Foo 6{ 7 public function bar(Foo $foo) 8 { 9 } 10 11 public function baz(Foo $foo) 12 { 13 } 14} 15 16require __DIR__ . '/../../../vendor/autoload.php'; 17 18$generator = new PHPUnit_Framework_MockObject_Generator; 19 20$mock = $generator->generate( 21 'Foo', array(), 'ProxyFoo', true, true, true, true 22); 23 24print $mock['code']; 25?> 26--EXPECTF-- 27class ProxyFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject 28{ 29 private $__phpunit_invocationMocker; 30 private $__phpunit_originalObject; 31 private $__phpunit_configurable = ['bar', 'baz']; 32 33 public function __clone() 34 { 35 $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); 36 } 37 38 public function bar(Foo $foo) 39 { 40 $arguments = array($foo); 41 $count = func_num_args(); 42 43 if ($count > 1) { 44 $_arguments = func_get_args(); 45 46 for ($i = 1; $i < $count; $i++) { 47 $arguments[] = $_arguments[$i]; 48 } 49 } 50 51 $this->__phpunit_getInvocationMocker()->invoke( 52 new PHPUnit_Framework_MockObject_Invocation_Object( 53 'Foo', 'bar', $arguments, '', $this, true 54 ) 55 ); 56 57 return call_user_func_array(array($this->__phpunit_originalObject, "bar"), $arguments); 58 } 59 60 public function baz(Foo $foo) 61 { 62 $arguments = array($foo); 63 $count = func_num_args(); 64 65 if ($count > 1) { 66 $_arguments = func_get_args(); 67 68 for ($i = 1; $i < $count; $i++) { 69 $arguments[] = $_arguments[$i]; 70 } 71 } 72 73 $this->__phpunit_getInvocationMocker()->invoke( 74 new PHPUnit_Framework_MockObject_Invocation_Object( 75 'Foo', 'baz', $arguments, '', $this, true 76 ) 77 ); 78 79 return call_user_func_array(array($this->__phpunit_originalObject, "baz"), $arguments); 80 } 81 82 public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) 83 { 84 return $this->__phpunit_getInvocationMocker()->expects($matcher); 85 } 86 87 public function method() 88 { 89 $any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount; 90 $expects = $this->expects($any); 91 return call_user_func_array(array($expects, 'method'), func_get_args()); 92 } 93 94 public function __phpunit_setOriginalObject($originalObject) 95 { 96 $this->__phpunit_originalObject = $originalObject; 97 } 98 99 public function __phpunit_getInvocationMocker() 100 { 101 if ($this->__phpunit_invocationMocker === null) { 102 $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable); 103 } 104 105 return $this->__phpunit_invocationMocker; 106 } 107 108 public function __phpunit_hasMatchers() 109 { 110 return $this->__phpunit_getInvocationMocker()->hasMatchers(); 111 } 112 113 public function __phpunit_verify($unsetInvocationMocker = true) 114 { 115 $this->__phpunit_getInvocationMocker()->verify(); 116 117 if ($unsetInvocationMocker) { 118 $this->__phpunit_invocationMocker = null; 119 } 120 } 121} 122