This commit is contained in:
aschwarz
2023-05-12 12:27:19 +02:00
parent 757c2388de
commit e2f1846f03
1974 changed files with 255998 additions and 0 deletions

View File

@ -0,0 +1,200 @@
<?php
/**
* @covers PHPUnit_Framework_MockObject_Generator
*
* @uses PHPUnit_Framework_MockObject_InvocationMocker
* @uses PHPUnit_Framework_MockObject_Builder_InvocationMocker
* @uses PHPUnit_Framework_MockObject_Invocation_Object
* @uses PHPUnit_Framework_MockObject_Invocation_Static
* @uses PHPUnit_Framework_MockObject_Matcher
* @uses PHPUnit_Framework_MockObject_Matcher_InvokedRecorder
* @uses PHPUnit_Framework_MockObject_Matcher_MethodName
* @uses PHPUnit_Framework_MockObject_Stub_Return
* @uses PHPUnit_Framework_MockObject_Matcher_InvokedCount
*/
class Framework_MockObject_GeneratorTest extends PHPUnit_Framework_TestCase
{
/**
* @var PHPUnit_Framework_MockObject_Generator
*/
private $generator;
protected function setUp()
{
$this->generator = new PHPUnit_Framework_MockObject_Generator;
}
/**
* @expectedException PHPUnit_Framework_MockObject_RuntimeException
*/
public function testGetMockFailsWhenInvalidFunctionNameIsPassedInAsAFunctionToMock()
{
$this->generator->getMock(stdClass::class, [0]);
}
public function testGetMockCanCreateNonExistingFunctions()
{
$mock = $this->generator->getMock(stdClass::class, ['testFunction']);
$this->assertTrue(method_exists($mock, 'testFunction'));
}
/**
* @expectedException PHPUnit_Framework_MockObject_RuntimeException
* @expectedExceptionMessage duplicates: "foo, bar, foo" (duplicate: "foo")
*/
public function testGetMockGeneratorFails()
{
$this->generator->getMock(stdClass::class, ['foo', 'bar', 'foo']);
}
/**
* @requires PHP 7
*/
public function testGetMockBlacklistedMethodNamesPhp7()
{
$mock = $this->generator->getMock(InterfaceWithSemiReservedMethodName::class);
$this->assertTrue(method_exists($mock, 'unset'));
$this->assertInstanceOf(InterfaceWithSemiReservedMethodName::class, $mock);
}
public function testGetMockForAbstractClassDoesNotFailWhenFakingInterfaces()
{
$mock = $this->generator->getMockForAbstractClass(Countable::class);
$this->assertTrue(method_exists($mock, 'count'));
}
public function testGetMockForAbstractClassStubbingAbstractClass()
{
$mock = $this->generator->getMockForAbstractClass(AbstractMockTestClass::class);
$this->assertTrue(method_exists($mock, 'doSomething'));
}
public function testGetMockForAbstractClassWithNonExistentMethods()
{
$mock = $this->generator->getMockForAbstractClass(
AbstractMockTestClass::class,
[],
'',
true,
true,
true,
['nonexistentMethod']
);
$this->assertTrue(method_exists($mock, 'nonexistentMethod'));
$this->assertTrue(method_exists($mock, 'doSomething'));
}
public function testGetMockForAbstractClassShouldCreateStubsOnlyForAbstractMethodWhenNoMethodsWereInformed()
{
$mock = $this->generator->getMockForAbstractClass(AbstractMockTestClass::class);
$mock->expects($this->any())
->method('doSomething')
->willReturn('testing');
$this->assertEquals('testing', $mock->doSomething());
$this->assertEquals(1, $mock->returnAnything());
}
/**
* @dataProvider getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider
* @expectedException PHPUnit_Framework_Exception
*/
public function testGetMockForAbstractClassExpectingInvalidArgumentException($className, $mockClassName)
{
$this->generator->getMockForAbstractClass($className, [], $mockClassName);
}
/**
* @expectedException PHPUnit_Framework_MockObject_RuntimeException
*/
public function testGetMockForAbstractClassAbstractClassDoesNotExist()
{
$this->generator->getMockForAbstractClass('Tux');
}
public function getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider()
{
return [
'className not a string' => [[], ''],
'mockClassName not a string' => [Countable::class, new stdClass],
];
}
public function testGetMockForTraitWithNonExistentMethodsAndNonAbstractMethods()
{
$mock = $this->generator->getMockForTrait(
AbstractTrait::class,
[],
'',
true,
true,
true,
['nonexistentMethod']
);
$this->assertTrue(method_exists($mock, 'nonexistentMethod'));
$this->assertTrue(method_exists($mock, 'doSomething'));
$this->assertTrue($mock->mockableMethod());
$this->assertTrue($mock->anotherMockableMethod());
}
public function testGetMockForTraitStubbingAbstractMethod()
{
$mock = $this->generator->getMockForTrait(AbstractTrait::class);
$this->assertTrue(method_exists($mock, 'doSomething'));
}
public function testGetMockForSingletonWithReflectionSuccess()
{
$mock = $this->generator->getMock(SingletonClass::class, ['doSomething'], [], '', false);
$this->assertInstanceOf('SingletonClass', $mock);
}
/**
* @expectedException PHPUnit_Framework_MockObject_RuntimeException
*/
public function testExceptionIsRaisedForMutuallyExclusiveOptions()
{
$this->generator->getMock(stdClass::class, [], [], '', false, true, true, true, true);
}
/**
* @requires PHP 7
*/
public function testCanImplementInterfacesThatHaveMethodsWithReturnTypes()
{
$stub = $this->generator->getMock([AnInterfaceWithReturnType::class, AnInterface::class]);
$this->assertInstanceOf(AnInterfaceWithReturnType::class, $stub);
$this->assertInstanceOf(AnInterface::class, $stub);
$this->assertInstanceOf(PHPUnit_Framework_MockObject_MockObject::class, $stub);
}
public function testCanConfigureMethodsForDoubleOfNonExistentClass()
{
$className = 'X' . md5(microtime());
$mock = $this->generator->getMock($className, ['someMethod']);
$this->assertInstanceOf($className, $mock);
}
public function testCanInvokeMethodsOfNonExistentClass()
{
$className = 'X' . md5(microtime());
$mock = $this->generator->getMock($className, ['someMethod']);
$mock->expects($this->once())->method('someMethod');
$this->assertNull($mock->someMethod());
}
}

View File

@ -0,0 +1,126 @@
<?php
/*
* This file is part of the PHPUnit_MockObject package.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Framework_MockBuilderTest extends PHPUnit_Framework_TestCase
{
public function testMockBuilderRequiresClassName()
{
$mock = $this->getMockBuilder(Mockable::class)->getMock();
$this->assertTrue($mock instanceof Mockable);
}
public function testByDefaultMocksAllMethods()
{
$mock = $this->getMockBuilder(Mockable::class)->getMock();
$this->assertNull($mock->mockableMethod());
$this->assertNull($mock->anotherMockableMethod());
}
public function testMethodsToMockCanBeSpecified()
{
$mock = $this->getMockBuilder(Mockable::class)
->setMethods(['mockableMethod'])
->getMock();
$this->assertNull($mock->mockableMethod());
$this->assertTrue($mock->anotherMockableMethod());
}
public function testMethodExceptionsToMockCanBeSpecified()
{
$mock = $this->getMockBuilder(Mockable::class)
->setMethodsExcept(['mockableMethod'])
->getMock();
$this->assertTrue($mock->mockableMethod());
$this->assertNull($mock->anotherMockableMethod());
}
public function testEmptyMethodExceptionsToMockCanBeSpecified()
{
$mock = $this->getMockBuilder(Mockable::class)
->setMethodsExcept()
->getMock();
$this->assertNull($mock->mockableMethod());
$this->assertNull($mock->anotherMockableMethod());
}
public function testByDefaultDoesNotPassArgumentsToTheConstructor()
{
$mock = $this->getMockBuilder(Mockable::class)->getMock();
$this->assertEquals([null, null], $mock->constructorArgs);
}
public function testMockClassNameCanBeSpecified()
{
$mock = $this->getMockBuilder(Mockable::class)
->setMockClassName('ACustomClassName')
->getMock();
$this->assertTrue($mock instanceof ACustomClassName);
}
public function testConstructorArgumentsCanBeSpecified()
{
$mock = $this->getMockBuilder(Mockable::class)
->setConstructorArgs([23, 42])
->getMock();
$this->assertEquals([23, 42], $mock->constructorArgs);
}
public function testOriginalConstructorCanBeDisabled()
{
$mock = $this->getMockBuilder(Mockable::class)
->disableOriginalConstructor()
->getMock();
$this->assertNull($mock->constructorArgs);
}
public function testByDefaultOriginalCloneIsPreserved()
{
$mock = $this->getMockBuilder(Mockable::class)
->getMock();
$cloned = clone $mock;
$this->assertTrue($cloned->cloned);
}
public function testOriginalCloneCanBeDisabled()
{
$mock = $this->getMockBuilder(Mockable::class)
->disableOriginalClone()
->getMock();
$mock->cloned = false;
$cloned = clone $mock;
$this->assertFalse($cloned->cloned);
}
public function testProvidesAFluentInterface()
{
$spec = $this->getMockBuilder(Mockable::class)
->setMethods(['mockableMethod'])
->setConstructorArgs([])
->setMockClassName('DummyClassName')
->disableOriginalConstructor()
->disableOriginalClone()
->disableAutoload();
$this->assertTrue($spec instanceof PHPUnit_Framework_MockObject_MockBuilder);
}
}

View File

@ -0,0 +1,63 @@
<?php
class Framework_MockObject_Builder_InvocationMockerTest extends PHPUnit_Framework_TestCase
{
public function testWillReturnWithOneValue()
{
$mock = $this->getMockBuilder(stdClass::class)
->setMethods(['foo'])
->getMock();
$mock->expects($this->any())
->method('foo')
->willReturn(1);
$this->assertEquals(1, $mock->foo());
}
public function testWillReturnWithMultipleValues()
{
$mock = $this->getMockBuilder(stdClass::class)
->setMethods(['foo'])
->getMock();
$mock->expects($this->any())
->method('foo')
->willReturn(1, 2, 3);
$this->assertEquals(1, $mock->foo());
$this->assertEquals(2, $mock->foo());
$this->assertEquals(3, $mock->foo());
}
public function testWillReturnOnConsecutiveCalls()
{
$mock = $this->getMockBuilder(stdClass::class)
->setMethods(['foo'])
->getMock();
$mock->expects($this->any())
->method('foo')
->willReturnOnConsecutiveCalls(1, 2, 3);
$this->assertEquals(1, $mock->foo());
$this->assertEquals(2, $mock->foo());
$this->assertEquals(3, $mock->foo());
}
public function testWillReturnByReference()
{
$mock = $this->getMockBuilder(stdClass::class)
->setMethods(['foo'])
->getMock();
$mock->expects($this->any())
->method('foo')
->willReturnReference($value);
$this->assertSame(null, $mock->foo());
$value = 'foo';
$this->assertSame('foo', $mock->foo());
$value = 'bar';
$this->assertSame('bar', $mock->foo());
}
}

View File

@ -0,0 +1,129 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--FILE--
<?php
trait BaseTrait
{
protected function hello()
{
return 'hello';
}
}
trait ChildTrait
{
use BaseTrait
{
hello as private hi;
}
protected function hello()
{
return 'hi';
}
protected function world()
{
return $this->hi();
}
}
class Foo
{
use ChildTrait;
public function speak()
{
return $this->world();
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['speak'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function speak()
{
$arguments = array();
$count = func_num_args();
if ($count > 0) {
$_arguments = func_get_args();
for ($i = 0; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'speak', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,147 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--FILE--
<?php
abstract class Foo
{
public function one()
{
}
abstract public function two();
abstract protected function three();
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['one', 'two', 'three'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function one()
{
$arguments = array();
$count = func_num_args();
if ($count > 0) {
$_arguments = func_get_args();
for ($i = 0; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'one', $arguments, '', $this, true
)
);
return $result;
}
public function two()
{
$arguments = array();
$count = func_num_args();
if ($count > 0) {
$_arguments = func_get_args();
for ($i = 0; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'two', $arguments, '', $this, true
)
);
return $result;
}
protected function three()
{
$arguments = array();
$count = func_num_args();
if ($count > 0) {
$_arguments = func_get_args();
for ($i = 0; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'three', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,125 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--FILE--
<?php
class Foo
{
public function bar(Foo $foo)
{
}
public function baz(Foo $foo)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar', 'baz'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, '', $this, true
)
);
return $result;
}
public function baz(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'baz', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,77 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true)
--FILE--
<?php
class Foo
{
public function __clone()
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
parent::__clone();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,76 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true)
--FILE--
<?php
class Foo
{
public function __construct()
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,76 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', false)
--FILE--
<?php
class Foo
{
public function __clone()
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
false
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,76 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true)
--FILE--
<?php
class Foo
{
public function __construct()
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,81 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true)
--FILE--
<?php
interface IFoo
{
public function __construct($bar);
}
class Foo implements IFoo
{
public function __construct($bar)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,81 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true)
--FILE--
<?php
interface IFoo
{
public function __construct($bar);
}
class Foo implements IFoo
{
public function __construct($bar)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,103 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array('bar'), 'MockFoo', true, true)
--FILE--
<?php
class Foo
{
public function bar(Foo $foo)
{
}
public function baz(Foo $foo)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array('bar'),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,92 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--FILE--
<?php
class Foo
{
public function method()
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['method'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function method()
{
$arguments = array();
$count = func_num_args();
if ($count > 0) {
$_arguments = func_get_args();
for ($i = 0; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'method', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,99 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('ClassWithMethodWithVariadicArguments', array(), 'MockFoo', true, true)
--FILE--
<?php
class ClassWithMethodWithVariadicArguments
{
public function methodWithVariadicArguments($a, ...$parameters)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'ClassWithMethodWithVariadicArguments',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['methodwithvariadicarguments'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function methodWithVariadicArguments($a, ...$parameters)
{
$arguments = array($a);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'ClassWithMethodWithVariadicArguments', 'methodWithVariadicArguments', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,97 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--FILE--
<?php
interface Foo
{
public function bar(Foo $foo);
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,126 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true, true)
--FILE--
<?php
class Foo
{
public function bar(Foo $foo)
{
}
public function baz(Foo $foo)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar', 'baz'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, '', $this, true
)
);
return $result;
}
public function baz(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'baz', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,127 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true, true)
--FILE--
<?php
namespace NS;
class Foo
{
public function bar(Foo $foo)
{
}
public function baz(Foo $foo)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new \PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'NS\Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar', 'baz'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(NS\Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'NS\Foo', 'bar', $arguments, '', $this, true
)
);
return $result;
}
public function baz(NS\Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'NS\Foo', 'baz', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,79 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true)
--FILE--
<?php
namespace NS;
class Foo
{
public function __clone()
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new \PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'NS\Foo',
array(),
'MockFoo',
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
parent::__clone();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,78 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true)
--FILE--
<?php
namespace NS;
class Foo
{
public function __construct()
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new \PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'NS\Foo',
array(),
'MockFoo',
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,78 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', false)
--FILE--
<?php
namespace NS;
class Foo
{
public function __clone()
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new \PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'NS\Foo',
array(),
'MockFoo',
false
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,78 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true)
--FILE--
<?php
namespace NS;
class Foo
{
public function __construct()
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new \PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'NS\Foo',
array(),
'MockFoo',
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,83 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true)
--FILE--
<?php
namespace NS;
interface IFoo
{
public function __construct($bar);
}
class Foo implements IFoo
{
public function __construct($bar)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new \PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'NS\Foo',
array(),
'MockFoo',
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,83 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true)
--FILE--
<?php
namespace NS;
interface IFoo
{
public function __construct($bar);
}
class Foo implements IFoo
{
public function __construct($bar)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new \PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'NS\Foo',
array(),
'MockFoo',
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,105 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array('bar'), 'MockFoo', true, true)
--FILE--
<?php
namespace NS;
class Foo
{
public function bar(Foo $foo)
{
}
public function baz(Foo $foo)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new \PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'NS\Foo',
array('bar'),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(NS\Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'NS\Foo', 'bar', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,99 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', true, true)
--FILE--
<?php
namespace NS;
interface Foo
{
public function bar(Foo $foo);
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new \PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'NS\Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, NS\Foo
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(NS\Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'NS\Foo', 'bar', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,74 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NonExistentClass', array(), 'MockFoo', true, true)
--FILE--
<?php
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'NonExistentClass',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class NonExistentClass
{
}
class MockFoo extends NonExistentClass implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,82 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--FILE--
<?php
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'NS\Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
namespace NS {
class Foo
{
}
}
namespace {
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}
}

View File

@ -0,0 +1,82 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--FILE--
<?php
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'\NS\Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
namespace NS {
class Foo
{
}
}
namespace {
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = [];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}
}

View File

@ -0,0 +1,103 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--SKIPIF--
<?php
if (!version_compare(PHP_VERSION, '7.1', '>=')) print 'skip: PHP >= 7.1 required';
?>
--FILE--
<?php
class Foo
{
public function bar(?int $x)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(?int $x)
{
$arguments = array($x);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,121 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', null, 'ProxyFoo', true, true, true, true)
--FILE--
<?php
class Foo
{
public function bar(Foo $foo)
{
}
public function baz(Foo $foo)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo', array(), 'ProxyFoo', true, true, true, true
);
print $mock['code'];
?>
--EXPECTF--
class ProxyFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar', 'baz'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, '', $this, true
)
);
return call_user_func_array(array($this->__phpunit_originalObject, "bar"), $arguments);
}
public function baz(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'baz', $arguments, '', $this, true
)
);
return call_user_func_array(array($this->__phpunit_originalObject, "baz"), $arguments);
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,101 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--SKIPIF--
<?php
if (!version_compare(PHP_VERSION, '7.1', '>=')) print 'skip: PHP >= 7.1 required';
?>
--FILE--
<?php
interface Foo
{
public function bar(string $baz): ?string;
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(string $baz): ?string
{
$arguments = array($baz);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, '?string', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,104 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--SKIPIF--
<?php
if (!version_compare(PHP_VERSION, '7.0', '>=')) print 'skip: PHP >= 7.0 required';
?>
--FILE--
<?php
class Foo
{
public function bar(string $baz): Bar
{
return 'test';
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(string $baz): Bar
{
$arguments = array($baz);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, 'Bar', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,101 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--SKIPIF--
<?php
if (!version_compare(PHP_VERSION, '7.0', '>=')) print 'skip: PHP >= 7.0 required';
?>
--FILE--
<?php
interface Foo
{
public function bar(string $baz): self;
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(string $baz): Foo
{
$arguments = array($baz);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, 'Foo', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,87 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--SKIPIF--
<?php
if (!version_compare(PHP_VERSION, '7.0', '>=')) print 'skip: PHP >= 7.0 required';
?>
--FILE--
<?php
class Foo
{
public static function bar(string $baz): Bar
{
return 'test';
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public static function bar(string $baz): Bar
{
throw new PHPUnit_Framework_MockObject_BadMethodCallException('Static method "bar" cannot be invoked on mock object');
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,99 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--SKIPIF--
<?php
if (!version_compare(PHP_VERSION, '7.1', '>=')) print 'skip: PHP >= 7.1 required';
?>
--FILE--
<?php
interface Foo
{
public function bar(string $baz): void;
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(string $baz): void
{
$arguments = array($baz);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, 'void', $this, true
)
);
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,103 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', true, true)
--SKIPIF--
<?php
if (!version_compare(PHP_VERSION, '7.0', '>=')) print 'skip: PHP >= 7.0 required';
?>
--FILE--
<?php
class Foo
{
public function bar(string $baz)
{
}
}
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'Foo',
array(),
'MockFoo',
true,
true
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['bar'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function bar(string $baz)
{
$arguments = array($baz);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

View File

@ -0,0 +1,37 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch')
--SKIPIF--
<?php
if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
?>
--FILE--
<?php
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
print $generator->generateClassFromWsdl(
__DIR__ . '/../../_fixture/GoogleSearch.wsdl',
'GoogleSearch'
);
?>
--EXPECTF--
class GoogleSearch extends \SoapClient
{
public function __construct($wsdl, array $options)
{
parent::__construct('%s/GoogleSearch.wsdl', $options);
}
public function doGoogleSearch($key, $q, $start, $maxResults, $filter, $restrict, $safeSearch, $lr, $ie, $oe)
{
}
public function doGetCachedPage($key, $url)
{
}
public function doSpellingSuggestion($key, $phrase)
{
}
}

View File

@ -0,0 +1,39 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch')
--SKIPIF--
<?php
if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
?>
--FILE--
<?php
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
print $generator->generateClassFromWsdl(
__DIR__ . '/../../_fixture/GoogleSearch.wsdl',
'My\\Space\\GoogleSearch'
);
?>
--EXPECTF--
namespace My\Space;
class GoogleSearch extends \SoapClient
{
public function __construct($wsdl, array $options)
{
parent::__construct('%s/GoogleSearch.wsdl', $options);
}
public function doGoogleSearch($key, $q, $start, $maxResults, $filter, $restrict, $safeSearch, $lr, $ie, $oe)
{
}
public function doGetCachedPage($key, $url)
{
}
public function doSpellingSuggestion($key, $phrase)
{
}
}

View File

@ -0,0 +1,30 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch', array('doGoogleSearch'))
--SKIPIF--
<?php
if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
?>
--FILE--
<?php
require __DIR__ . '/../../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
print $generator->generateClassFromWsdl(
__DIR__ . '/../../_fixture/GoogleSearch.wsdl',
'GoogleSearch',
array('doGoogleSearch')
);
?>
--EXPECTF--
class GoogleSearch extends \SoapClient
{
public function __construct($wsdl, array $options)
{
parent::__construct('%s/GoogleSearch.wsdl', $options);
}
public function doGoogleSearch($key, $q, $start, $maxResults, $filter, $restrict, $safeSearch, $lr, $ie, $oe)
{
}
}

View File

@ -0,0 +1,108 @@
<?php
class Framework_MockObject_Invocation_ObjectTest extends PHPUnit_Framework_TestCase
{
public function testConstructorRequiresClassAndMethodAndParametersAndObject()
{
$this->assertInstanceOf(
PHPUnit_Framework_MockObject_Invocation_Object::class,
new PHPUnit_Framework_MockObject_Invocation_Object(
'FooClass',
'FooMethod',
['an_argument'],
'ReturnType',
new stdClass
)
);
}
public function testAllowToGetClassNameSetInConstructor()
{
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
'FooClass',
'FooMethod',
['an_argument'],
'ReturnType',
new stdClass
);
$this->assertSame('FooClass', $invocation->className);
}
public function testAllowToGetMethodNameSetInConstructor()
{
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
'FooClass',
'FooMethod',
['an_argument'],
'ReturnType',
new stdClass
);
$this->assertSame('FooMethod', $invocation->methodName);
}
public function testAllowToGetObjectSetInConstructor()
{
$expectedObject = new stdClass;
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
'FooClass',
'FooMethod',
['an_argument'],
'ReturnType',
$expectedObject
);
$this->assertSame($expectedObject, $invocation->object);
}
public function testAllowToGetMethodParametersSetInConstructor()
{
$expectedParameters = [
'foo', 5, ['a', 'b'], new stdClass, null, false
];
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
'FooClass',
'FooMethod',
$expectedParameters,
'ReturnType',
new stdClass
);
$this->assertSame($expectedParameters, $invocation->parameters);
}
public function testConstructorAllowToSetFlagCloneObjectsInParameters()
{
$parameters = [new stdClass];
$cloneObjects = true;
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
'FooClass',
'FooMethod',
$parameters,
'ReturnType',
new stdClass,
$cloneObjects
);
$this->assertEquals($parameters, $invocation->parameters);
$this->assertNotSame($parameters, $invocation->parameters);
}
public function testAllowToGetReturnTypeSetInConstructor()
{
$expectedReturnType = 'string';
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
'FooClass',
'FooMethod',
['an_argument'],
$expectedReturnType,
new stdClass
);
$this->assertSame($expectedReturnType, $invocation->returnType);
}
}

View File

@ -0,0 +1,87 @@
<?php
class Framework_MockObject_Invocation_StaticTest extends PHPUnit_Framework_TestCase
{
public function testConstructorRequiresClassAndMethodAndParameters()
{
$this->assertInstanceOf(
PHPUnit_Framework_MockObject_Invocation_Static::class,
new PHPUnit_Framework_MockObject_Invocation_Static(
'FooClass',
'FooMethod',
['an_argument'],
'ReturnType'
)
);
}
public function testAllowToGetClassNameSetInConstructor()
{
$invocation = new PHPUnit_Framework_MockObject_Invocation_Static(
'FooClass',
'FooMethod',
['an_argument'],
'ReturnType'
);
$this->assertSame('FooClass', $invocation->className);
}
public function testAllowToGetMethodNameSetInConstructor()
{
$invocation = new PHPUnit_Framework_MockObject_Invocation_Static(
'FooClass',
'FooMethod',
['an_argument'],
'ReturnType'
);
$this->assertSame('FooMethod', $invocation->methodName);
}
public function testAllowToGetMethodParametersSetInConstructor()
{
$expectedParameters = [
'foo', 5, ['a', 'b'], new stdClass, null, false
];
$invocation = new PHPUnit_Framework_MockObject_Invocation_Static(
'FooClass',
'FooMethod',
$expectedParameters,
'ReturnType'
);
$this->assertSame($expectedParameters, $invocation->parameters);
}
public function testConstructorAllowToSetFlagCloneObjectsInParameters()
{
$parameters = [new stdClass];
$cloneObjects = true;
$invocation = new PHPUnit_Framework_MockObject_Invocation_Static(
'FooClass',
'FooMethod',
$parameters,
'ReturnType',
$cloneObjects
);
$this->assertEquals($parameters, $invocation->parameters);
$this->assertNotSame($parameters, $invocation->parameters);
}
public function testAllowToGetReturnTypeSetInConstructor()
{
$expectedReturnType = 'string';
$invocation = new PHPUnit_Framework_MockObject_Invocation_Static(
'FooClass',
'FooMethod',
['an_argument'],
$expectedReturnType
);
$this->assertSame($expectedReturnType, $invocation->returnType);
}
}

View File

@ -0,0 +1,56 @@
<?php
class Framework_MockObject_Matcher_ConsecutiveParametersTest extends PHPUnit_Framework_TestCase
{
public function testIntegration()
{
$mock = $this->getMockBuilder(stdClass::class)
->setMethods(['foo'])
->getMock();
$mock->expects($this->any())
->method('foo')
->withConsecutive(
['bar'],
[21, 42]
);
$this->assertNull($mock->foo('bar'));
$this->assertNull($mock->foo(21, 42));
}
public function testIntegrationWithLessAssertionsThanMethodCalls()
{
$mock = $this->getMockBuilder(stdClass::class)
->setMethods(['foo'])
->getMock();
$mock->expects($this->any())
->method('foo')
->withConsecutive(
['bar']
);
$this->assertNull($mock->foo('bar'));
$this->assertNull($mock->foo(21, 42));
}
public function testIntegrationExpectingException()
{
$mock = $this->getMockBuilder(stdClass::class)
->setMethods(['foo'])
->getMock();
$mock->expects($this->any())
->method('foo')
->withConsecutive(
['bar'],
[21, 42]
);
$mock->foo('bar');
$this->expectException(PHPUnit_Framework_ExpectationFailedException::class);
$mock->foo('invalid');
}
}

View File

@ -0,0 +1,105 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('ClassWithDeprecatedMethod', array(), 'MockFoo', TRUE, TRUE)
--FILE--
<?php
class ClassWithDeprecatedMethod
{
/**
* @deprecated this method
* is deprecated
*/
public function deprecatedMethod()
{
}
}
require __DIR__ . '/../../vendor/autoload.php';
$generator = new PHPUnit_Framework_MockObject_Generator;
$mock = $generator->generate(
'ClassWithDeprecatedMethod',
array(),
'MockFoo',
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends ClassWithDeprecatedMethod implements PHPUnit_Framework_MockObject_MockObject
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = ['deprecatedmethod'];
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}
public function deprecatedMethod()
{
@trigger_error('The ClassWithDeprecatedMethod::deprecatedMethod method is deprecated (this method is deprecated).', E_USER_DEPRECATED);
$arguments = array();
$count = func_num_args();
if ($count > 0) {
$_arguments = func_get_args();
for ($i = 0; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'ClassWithDeprecatedMethod', 'deprecatedMethod', $arguments, '', $this, true
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public function method()
{
$any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array(array($expects, 'method'), func_get_args());
}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker($this->__phpunit_configurable);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
<?php
/*
* This file is part of the PHPUnit_MockObject package.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Framework_ProxyObjectTest extends PHPUnit_Framework_TestCase
{
public function testMockedMethodIsProxiedToOriginalMethod()
{
$proxy = $this->getMockBuilder(Bar::class)
->enableProxyingToOriginalMethods()
->getMock();
$proxy->expects($this->once())
->method('doSomethingElse');
$foo = new Foo;
$this->assertEquals('result', $foo->doSomething($proxy));
}
public function testMockedMethodWithReferenceIsProxiedToOriginalMethod()
{
$proxy = $this->getMockBuilder(MethodCallbackByReference::class)
->enableProxyingToOriginalMethods()
->getMock();
$a = $b = $c = 0;
$proxy->callback($a, $b, $c);
$this->assertEquals(1, $b);
}
}

View File

@ -0,0 +1,10 @@
<?php
abstract class AbstractMockTestClass implements MockTestInterface
{
abstract public function doSomething();
public function returnAnything()
{
return 1;
}
}

View File

@ -0,0 +1,15 @@
<?php
trait AbstractTrait
{
abstract public function doSomething();
public function mockableMethod()
{
return true;
}
public function anotherMockableMethod()
{
return true;
}
}

View File

@ -0,0 +1,5 @@
<?php
interface AnInterface
{
public function doSomething();
}

View File

@ -0,0 +1,5 @@
<?php
interface AnInterfaceWithReturnType
{
public function returnAnArray(): array;
}

View File

@ -0,0 +1,5 @@
<?php
interface AnotherInterface
{
public function doSomethingElse();
}

View File

@ -0,0 +1,8 @@
<?php
class Bar
{
public function doSomethingElse()
{
return 'result';
}
}

View File

@ -0,0 +1,15 @@
<?php
class ClassThatImplementsSerializable implements Serializable
{
public function serialize()
{
return get_object_vars($this);
}
public function unserialize($serialized)
{
foreach (unserialize($serialized) as $key => $value) {
$this->{$key} = $value;
}
}
}

View File

@ -0,0 +1,7 @@
<?php
class ClassWithSelfTypeHint
{
public function foo(self $foo)
{
}
}

View File

@ -0,0 +1,7 @@
<?php
class ClassWithStaticMethod
{
public static function staticMethod()
{
}
}

View File

@ -0,0 +1,8 @@
<?php
class Foo
{
public function doSomething(Bar $bar)
{
return $bar->doSomethingElse();
}
}

View File

@ -0,0 +1,9 @@
<?php
function functionCallback()
{
$args = func_get_args();
if ($args == ['foo', 'bar']) {
return 'pass';
}
}

View File

@ -0,0 +1,198 @@
<?xml version="1.0"?>
<!-- WSDL description of the Google Web APIs.
The Google Web APIs are in beta release. All interfaces are subject to
change as we refine and extend our APIs. Please see the terms of use
for more information. -->
<!-- Revision 2002-08-16 -->
<definitions name="GoogleSearch"
targetNamespace="urn:GoogleSearch"
xmlns:typens="urn:GoogleSearch"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<!-- Types for search - result elements, directory categories -->
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:GoogleSearch">
<xsd:complexType name="GoogleSearchResult">
<xsd:all>
<xsd:element name="documentFiltering" type="xsd:boolean"/>
<xsd:element name="searchComments" type="xsd:string"/>
<xsd:element name="estimatedTotalResultsCount" type="xsd:int"/>
<xsd:element name="estimateIsExact" type="xsd:boolean"/>
<xsd:element name="resultElements" type="typens:ResultElementArray"/>
<xsd:element name="searchQuery" type="xsd:string"/>
<xsd:element name="startIndex" type="xsd:int"/>
<xsd:element name="endIndex" type="xsd:int"/>
<xsd:element name="searchTips" type="xsd:string"/>
<xsd:element name="directoryCategories" type="typens:DirectoryCategoryArray"/>
<xsd:element name="searchTime" type="xsd:double"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="ResultElement">
<xsd:all>
<xsd:element name="summary" type="xsd:string"/>
<xsd:element name="URL" type="xsd:string"/>
<xsd:element name="snippet" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="cachedSize" type="xsd:string"/>
<xsd:element name="relatedInformationPresent" type="xsd:boolean"/>
<xsd:element name="hostName" type="xsd:string"/>
<xsd:element name="directoryCategory" type="typens:DirectoryCategory"/>
<xsd:element name="directoryTitle" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="ResultElementArray">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:ResultElement[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="DirectoryCategoryArray">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:DirectoryCategory[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="DirectoryCategory">
<xsd:all>
<xsd:element name="fullViewableName" type="xsd:string"/>
<xsd:element name="specialEncoding" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
</types>
<!-- Messages for Google Web APIs - cached page, search, spelling. -->
<message name="doGetCachedPage">
<part name="key" type="xsd:string"/>
<part name="url" type="xsd:string"/>
</message>
<message name="doGetCachedPageResponse">
<part name="return" type="xsd:base64Binary"/>
</message>
<message name="doSpellingSuggestion">
<part name="key" type="xsd:string"/>
<part name="phrase" type="xsd:string"/>
</message>
<message name="doSpellingSuggestionResponse">
<part name="return" type="xsd:string"/>
</message>
<!-- note, ie and oe are ignored by server; all traffic is UTF-8. -->
<message name="doGoogleSearch">
<part name="key" type="xsd:string"/>
<part name="q" type="xsd:string"/>
<part name="start" type="xsd:int"/>
<part name="maxResults" type="xsd:int"/>
<part name="filter" type="xsd:boolean"/>
<part name="restrict" type="xsd:string"/>
<part name="safeSearch" type="xsd:boolean"/>
<part name="lr" type="xsd:string"/>
<part name="ie" type="xsd:string"/>
<part name="oe" type="xsd:string"/>
</message>
<message name="doGoogleSearchResponse">
<part name="return" type="typens:GoogleSearchResult"/>
</message>
<!-- Port for Google Web APIs, "GoogleSearch" -->
<portType name="GoogleSearchPort">
<operation name="doGetCachedPage">
<input message="typens:doGetCachedPage"/>
<output message="typens:doGetCachedPageResponse"/>
</operation>
<operation name="doSpellingSuggestion">
<input message="typens:doSpellingSuggestion"/>
<output message="typens:doSpellingSuggestionResponse"/>
</operation>
<operation name="doGoogleSearch">
<input message="typens:doGoogleSearch"/>
<output message="typens:doGoogleSearchResponse"/>
</operation>
</portType>
<!-- Binding for Google Web APIs - RPC, SOAP over HTTP -->
<binding name="GoogleSearchBinding" type="typens:GoogleSearchPort">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="doGetCachedPage">
<soap:operation soapAction="urn:GoogleSearchAction"/>
<input>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="doSpellingSuggestion">
<soap:operation soapAction="urn:GoogleSearchAction"/>
<input>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="doGoogleSearch">
<soap:operation soapAction="urn:GoogleSearchAction"/>
<input>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<!-- Endpoint for Google Web APIs -->
<service name="GoogleSearchService">
<port name="GoogleSearchPort" binding="typens:GoogleSearchBinding">
<soap:address location="http://api.google.com/search/beta2"/>
</port>
</service>
</definitions>

View File

@ -0,0 +1,5 @@
<?php
interface InterfaceWithSemiReservedMethodName
{
public function unset();
}

View File

@ -0,0 +1,5 @@
<?php
interface InterfaceWithStaticMethod
{
public static function staticMethod();
}

View File

@ -0,0 +1,21 @@
<?php
class MethodCallback
{
public static function staticCallback()
{
$args = func_get_args();
if ($args == ['foo', 'bar']) {
return 'pass';
}
}
public function nonStaticCallback()
{
$args = func_get_args();
if ($args == ['foo', 'bar']) {
return 'pass';
}
}
}

View File

@ -0,0 +1,13 @@
<?php
class MethodCallbackByReference
{
public function bar(&$a, &$b, $c)
{
Legacy::bar($a, $b, $c);
}
public function callback(&$a, &$b, $c)
{
$b = 1;
}
}

View File

@ -0,0 +1,6 @@
<?php
interface MockTestInterface
{
public function returnAnything();
public function returnAnythingElse();
}

View File

@ -0,0 +1,28 @@
<?php
class Mockable
{
public $constructorArgs;
public $cloned;
public function __construct($arg1 = null, $arg2 = null)
{
$this->constructorArgs = [$arg1, $arg2];
}
public function mockableMethod()
{
// something different from NULL
return true;
}
public function anotherMockableMethod()
{
// something different from NULL
return true;
}
public function __clone()
{
$this->cloned = true;
}
}

View File

@ -0,0 +1,18 @@
<?php
class PartialMockTestClass
{
public $constructorCalled = false;
public function __construct()
{
$this->constructorCalled = true;
}
public function doSomething()
{
}
public function doAnotherThing()
{
}
}

View File

@ -0,0 +1,28 @@
<?php
class SingletonClass
{
public static function getInstance()
{
}
public function doSomething()
{
}
protected function __construct()
{
}
final private function __sleep()
{
}
final private function __wakeup()
{
}
final private function __clone()
{
}
}

View File

@ -0,0 +1,13 @@
<?php
class SomeClass
{
public function doSomething($a, $b)
{
return;
}
public function doSomethingElse($c)
{
return;
}
}

View File

@ -0,0 +1,12 @@
<?php
class StaticMockTestClass
{
public static function doSomething()
{
}
public static function doSomethingElse()
{
return static::doSomething();
}
}

View File

@ -0,0 +1,8 @@
<?php
class StringableClass
{
public function __toString()
{
return '12345';
}
}

View File

@ -0,0 +1,4 @@
<?php
interface TraversableMockTestInterface extends Traversable
{
}

View File

@ -0,0 +1,3 @@
<?php
require __DIR__ . '/_fixture/FunctionCallback.php';
require __DIR__ . '/../vendor/autoload.php';