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