Laravel version update
Laravel version update
This commit is contained in:
74
vendor/phpunit/phpunit-mock-objects/tests/Builder/InvocationMockerTest.php
vendored
Normal file
74
vendor/phpunit/phpunit-mock-objects/tests/Builder/InvocationMockerTest.php
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class InvocationMockerTest extends 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());
|
||||
}
|
||||
}
|
@@ -1,9 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (version_compare(PHP_VERSION, '5.4.0', '<')) print 'skip: PHP >= 5.4.0 required';
|
||||
?>
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
trait BaseTrait
|
||||
@@ -44,23 +40,24 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['speak'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -81,22 +78,22 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'speak', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'speak', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -108,8 +105,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -120,10 +117,13 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
112
vendor/phpunit/phpunit-mock-objects/tests/Generator/3154_namespaced_constant_resolving.phpt
vendored
Normal file
112
vendor/phpunit/phpunit-mock-objects/tests/Generator/3154_namespaced_constant_resolving.phpt
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
--TEST--
|
||||
https://github.com/sebastianbergmann/phpunit-mock-objects/issues/420
|
||||
https://github.com/sebastianbergmann/phpunit/issues/3154
|
||||
--FILE--
|
||||
<?php
|
||||
namespace Is\Namespaced;
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (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.
|
||||
*/
|
||||
|
||||
const A_CONSTANT = 17;
|
||||
const PHP_VERSION = "0.0.0";
|
||||
|
||||
class Issue3154
|
||||
{
|
||||
public function a(int $i = PHP_INT_MAX, int $j = A_CONSTANT, string $v = \PHP_VERSION, string $z = '#'): string
|
||||
{
|
||||
return $z."sum: ".($i+$j).$v;
|
||||
}
|
||||
}
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
Issue3154::class,
|
||||
[],
|
||||
'Issue3154Mock',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
--EXPECT--
|
||||
class Issue3154Mock extends Is\Namespaced\Issue3154 implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['a'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function a(int $i = PHP_INT_MAX, int $j = Is\Namespaced\A_CONSTANT, string $v = PHP_VERSION, string $z = '#'): string
|
||||
{
|
||||
$arguments = array($i, $j, $v, $z);
|
||||
$count = func_num_args();
|
||||
|
||||
if ($count > 4) {
|
||||
$_arguments = func_get_args();
|
||||
|
||||
for ($i = 4; $i < $count; $i++) {
|
||||
$arguments[] = $_arguments[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Is\Namespaced\Issue3154', 'a', $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;
|
||||
}
|
||||
}
|
||||
}
|
101
vendor/phpunit/phpunit-mock-objects/tests/Generator/397.phpt
vendored
Normal file
101
vendor/phpunit/phpunit-mock-objects/tests/Generator/397.phpt
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
--TEST--
|
||||
https://github.com/sebastianbergmann/phpunit-mock-objects/issues/397
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!version_compare(PHP_VERSION, '7.1', '>=')) print 'skip: PHP >= 7.1 required';
|
||||
--FILE--
|
||||
<?php
|
||||
class C
|
||||
{
|
||||
public function m(?self $other): self
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
C::class,
|
||||
[],
|
||||
'MockC',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
--EXPECTF--
|
||||
class MockC extends C implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['m'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function m(?C $other): C
|
||||
{
|
||||
$arguments = array($other);
|
||||
$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\ObjectInvocation(
|
||||
'C', 'm', $arguments, 'C', $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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
abstract class Foo
|
||||
@@ -15,23 +15,24 @@ abstract class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['one', 'two', 'three'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -52,9 +53,9 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'one', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'one', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
@@ -74,9 +75,9 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'two', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'two', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
@@ -96,22 +97,22 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'three', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'three', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -123,8 +124,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -135,9 +136,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -15,23 +15,24 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar', 'baz'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -52,9 +53,9 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'bar', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
@@ -74,22 +75,22 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'baz', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'baz', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -101,8 +102,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -113,9 +114,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -11,22 +11,23 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -34,14 +35,14 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
parent::__clone();
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -53,8 +54,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -65,9 +66,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -11,36 +11,37 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -52,8 +53,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -64,9 +65,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', FALSE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', false)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -11,36 +11,37 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
FALSE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
false
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -52,8 +53,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -64,9 +65,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -11,36 +11,37 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -52,8 +53,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -64,9 +65,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,7 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
interface IFoo
|
||||
{
|
||||
public function __construct($bar);
|
||||
@@ -18,36 +16,37 @@ class Foo implements IFoo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -59,8 +58,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -71,9 +70,12 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,7 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
interface IFoo
|
||||
{
|
||||
public function __construct($bar);
|
||||
@@ -18,36 +16,37 @@ class Foo implements IFoo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -59,8 +58,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -71,9 +70,12 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array('bar'), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array('bar'), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -15,23 +15,24 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array('bar'),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array('bar'),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -52,22 +53,22 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'bar', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -79,8 +80,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -91,9 +92,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
105
vendor/phpunit/phpunit-mock-objects/tests/Generator/class_with_deprecated_method.phpt
vendored
Normal file
105
vendor/phpunit/phpunit-mock-objects/tests/Generator/class_with_deprecated_method.phpt
vendored
Normal 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\ObjectInvocation(
|
||||
'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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -11,23 +11,24 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['method'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -48,15 +49,15 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'method', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'method', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
public function expects(\PHPUnit\Framework\MockObject\Matcher\Invocation $matcher)
|
||||
{
|
||||
return $this->__phpunit_getInvocationMocker()->expects($matcher);
|
||||
}
|
||||
@@ -68,8 +69,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -80,9 +81,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
--TEST--
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('ClassWithMethodWithVariadicArguments', array(), 'MockFoo', true, true)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!version_compare(PHP_VERSION, '7.1', '>=')) print 'skip: PHP >= 7.1 required';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
class ClassWithMethodWithNullableTypehintedVariadicArguments
|
||||
{
|
||||
public function methodWithNullableTypehintedVariadicArguments($a, ?string ...$parameters)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'ClassWithMethodWithNullableTypehintedVariadicArguments',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends ClassWithMethodWithNullableTypehintedVariadicArguments implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['methodwithnullabletypehintedvariadicarguments'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function methodWithNullableTypehintedVariadicArguments($a, ?string ...$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\ObjectInvocation(
|
||||
'ClassWithMethodWithNullableTypehintedVariadicArguments', 'methodWithNullableTypehintedVariadicArguments', $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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,99 @@
|
||||
--TEST--
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('ClassWithMethodWithVariadicArguments', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class ClassWithMethodWithTypehintedVariadicArguments
|
||||
{
|
||||
public function methodWithTypehintedVariadicArguments($a, string ...$parameters)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'ClassWithMethodWithTypehintedVariadicArguments',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends ClassWithMethodWithTypehintedVariadicArguments implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['methodwithtypehintedvariadicarguments'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
|
||||
}
|
||||
|
||||
public function methodWithTypehintedVariadicArguments($a, string ...$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\ObjectInvocation(
|
||||
'ClassWithMethodWithTypehintedVariadicArguments', 'methodWithTypehintedVariadicArguments', $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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('ClassWithMethodWithVariadicArguments', array(), 'MockFoo', TRUE, TRUE)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (version_compare(PHP_VERSION, '5.6.0', '<')) print 'skip: PHP >= 5.6.0 required';
|
||||
?>
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('ClassWithMethodWithVariadicArguments', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class ClassWithMethodWithVariadicArguments
|
||||
@@ -15,23 +11,24 @@ class ClassWithMethodWithVariadicArguments
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'ClassWithMethodWithVariadicArguments',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'ClassWithMethodWithVariadicArguments',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['methodwithvariadicarguments'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -52,22 +49,22 @@ class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit_Fr
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'ClassWithMethodWithVariadicArguments', 'methodWithVariadicArguments', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'ClassWithMethodWithVariadicArguments', 'methodWithVariadicArguments', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -79,8 +76,8 @@ class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit_Fr
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -91,9 +88,12 @@ class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit_Fr
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
99
vendor/phpunit/phpunit-mock-objects/tests/Generator/constant_as_parameter_default_value.phpt
vendored
Normal file
99
vendor/phpunit/phpunit-mock-objects/tests/Generator/constant_as_parameter_default_value.phpt
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
--TEST--
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', [], 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function bar(int $baz = PHP_INT_MIN)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
[],
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECT--
|
||||
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 $baz = PHP_INT_MIN)
|
||||
{
|
||||
$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\ObjectInvocation(
|
||||
'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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
interface Foo
|
||||
@@ -9,23 +9,24 @@ interface Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
|
||||
class MockFoo implements PHPUnit\Framework\MockObject\MockObject, Foo
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -46,22 +47,22 @@ class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'bar', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -73,8 +74,8 @@ class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -85,9 +86,12 @@ class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -15,24 +15,25 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar', 'baz'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -53,9 +54,9 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'bar', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
@@ -75,22 +76,22 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'baz', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'baz', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -102,8 +103,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -114,9 +115,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
@@ -17,23 +17,24 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar', 'baz'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -54,9 +55,9 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'NS\Foo', 'bar', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'NS\Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
@@ -76,22 +77,22 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'NS\Foo', 'baz', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'NS\Foo', 'baz', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -103,8 +104,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -115,9 +116,12 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
@@ -13,22 +13,23 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = [];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -36,14 +37,14 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
parent::__clone();
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -55,8 +56,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -67,9 +68,12 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
@@ -13,36 +13,37 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -54,8 +55,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -66,9 +67,12 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', FALSE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', array(), 'MockFoo', false)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
@@ -13,36 +13,37 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
FALSE
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
false
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -54,8 +55,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -66,9 +67,12 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
@@ -13,36 +13,37 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -54,8 +55,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -66,9 +67,12 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,9 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
interface IFoo
|
||||
{
|
||||
public function __construct($bar);
|
||||
@@ -16,36 +18,37 @@ class Foo implements IFoo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -57,8 +60,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -69,9 +72,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,9 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', array(), 'MockFoo', true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
interface IFoo
|
||||
{
|
||||
public function __construct($bar);
|
||||
@@ -16,36 +18,37 @@ class Foo implements IFoo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -57,8 +60,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -69,9 +72,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array('bar'), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', array('bar'), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
@@ -17,23 +17,24 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array('bar'),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'NS\Foo',
|
||||
array('bar'),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -54,22 +55,22 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'NS\Foo', 'bar', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'NS\Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -81,8 +82,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -93,9 +94,12 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('NS\Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace NS;
|
||||
@@ -11,23 +11,24 @@ interface Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new \PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, NS\Foo
|
||||
class MockFoo implements PHPUnit\Framework\MockObject\MockObject, NS\Foo
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -48,22 +49,22 @@ class MockFoo implements PHPUnit_Framework_MockObject_MockObject, NS\Foo
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'NS\Foo', 'bar', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'NS\Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -75,8 +76,8 @@ class MockFoo implements PHPUnit_Framework_MockObject_MockObject, NS\Foo
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -87,9 +88,12 @@ class MockFoo implements PHPUnit_Framework_MockObject_MockObject, NS\Foo
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +1,17 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('NonExistentClass', array(), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('NonExistentClass', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NonExistentClass',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'NonExistentClass',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
@@ -21,24 +21,25 @@ class NonExistentClass
|
||||
{
|
||||
}
|
||||
|
||||
class MockFoo extends NonExistentClass implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -50,8 +51,8 @@ class MockFoo extends NonExistentClass implements PHPUnit_Framework_MockObject_M
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -62,9 +63,12 @@ class MockFoo extends NonExistentClass implements PHPUnit_Framework_MockObject_M
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +1,17 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
@@ -27,24 +27,25 @@ class Foo
|
||||
|
||||
namespace {
|
||||
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -56,8 +57,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -68,10 +69,13 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,17 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'\NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'\NS\Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
@@ -27,24 +27,25 @@ class Foo
|
||||
|
||||
namespace {
|
||||
|
||||
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -56,8 +57,8 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -68,10 +69,13 @@ class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
103
vendor/phpunit/phpunit-mock-objects/tests/Generator/nullable_types.phpt
vendored
Normal file
103
vendor/phpunit/phpunit-mock-objects/tests/Generator/nullable_types.phpt
vendored
Normal 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\ObjectInvocation(
|
||||
'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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', NULL, 'ProxyFoo', TRUE, TRUE, TRUE, TRUE)
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', null, 'ProxyFoo', true, true, true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -15,19 +15,20 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo', array(), 'ProxyFoo', TRUE, TRUE, TRUE, TRUE
|
||||
'Foo', array(), 'ProxyFoo', true, true, true, true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class ProxyFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class ProxyFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar', 'baz'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -48,9 +49,9 @@ class ProxyFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'bar', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return call_user_func_array(array($this->__phpunit_originalObject, "bar"), $arguments);
|
||||
@@ -70,22 +71,22 @@ class ProxyFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'baz', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'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)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -97,8 +98,8 @@ class ProxyFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -109,9 +110,12 @@ class ProxyFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
97
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_closure.phpt
vendored
Normal file
97
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_closure.phpt
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
--TEST--
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
interface Foo
|
||||
{
|
||||
public function bar(): Closure;
|
||||
}
|
||||
|
||||
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(): Closure
|
||||
{
|
||||
$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\ObjectInvocation(
|
||||
'Foo', 'bar', $arguments, 'Closure', $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;
|
||||
}
|
||||
}
|
||||
}
|
108
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_final.phpt
vendored
Normal file
108
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_final.phpt
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
--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
|
||||
final class FinalClass
|
||||
{
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function bar(): FinalClass
|
||||
{
|
||||
return new FinalClass();
|
||||
}
|
||||
}
|
||||
|
||||
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(): FinalClass
|
||||
{
|
||||
$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\ObjectInvocation(
|
||||
'Foo', 'bar', $arguments, 'FinalClass', $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;
|
||||
}
|
||||
}
|
||||
}
|
97
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_generator.phpt
vendored
Normal file
97
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_generator.phpt
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
--TEST--
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
interface Foo
|
||||
{
|
||||
public function bar(): Generator;
|
||||
}
|
||||
|
||||
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(): Generator
|
||||
{
|
||||
$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\ObjectInvocation(
|
||||
'Foo', 'bar', $arguments, 'Generator', $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;
|
||||
}
|
||||
}
|
||||
}
|
101
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_nullable.phpt
vendored
Normal file
101
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_nullable.phpt
vendored
Normal 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\ObjectInvocation(
|
||||
'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;
|
||||
}
|
||||
}
|
||||
}
|
100
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_object_method.phpt
vendored
Normal file
100
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_object_method.phpt
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
--TEST--
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--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\ObjectInvocation(
|
||||
'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;
|
||||
}
|
||||
}
|
||||
}
|
97
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_self.phpt
vendored
Normal file
97
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_self.phpt
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
--TEST--
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--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\ObjectInvocation(
|
||||
'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;
|
||||
}
|
||||
}
|
||||
}
|
83
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_static_method.phpt
vendored
Normal file
83
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_static_method.phpt
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
--TEST--
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--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;
|
||||
}
|
||||
}
|
||||
}
|
99
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_void.phpt
vendored
Normal file
99
vendor/phpunit/phpunit-mock-objects/tests/Generator/return_type_declarations_void.phpt
vendored
Normal 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\ObjectInvocation(
|
||||
'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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!method_exists('ReflectionParameter', 'hasType')) print 'skip: PHP >= 7.0.0 required';
|
||||
?>
|
||||
\PHPUnit\Framework\MockObject\Generator::generate('Foo', array(), 'MockFoo', true, true)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
@@ -15,23 +11,24 @@ class Foo
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
$mock = $generator->generate(
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
TRUE,
|
||||
TRUE
|
||||
'Foo',
|
||||
array(),
|
||||
'MockFoo',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
print $mock['code'];
|
||||
?>
|
||||
--EXPECTF--
|
||||
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObject
|
||||
{
|
||||
private $__phpunit_invocationMocker;
|
||||
private $__phpunit_originalObject;
|
||||
private $__phpunit_configurable = ['bar'];
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
@@ -52,22 +49,22 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
}
|
||||
|
||||
$result = $this->__phpunit_getInvocationMocker()->invoke(
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'Foo', 'bar', $arguments, $this, TRUE
|
||||
)
|
||||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
|
||||
'Foo', 'bar', $arguments, '', $this, true
|
||||
)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
|
||||
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;
|
||||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
|
||||
$expects = $this->expects($any);
|
||||
return call_user_func_array(array($expects, 'method'), func_get_args());
|
||||
}
|
||||
@@ -79,8 +76,8 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
|
||||
public function __phpunit_getInvocationMocker()
|
||||
{
|
||||
if ($this->__phpunit_invocationMocker === NULL) {
|
||||
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
|
||||
if ($this->__phpunit_invocationMocker === null) {
|
||||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable);
|
||||
}
|
||||
|
||||
return $this->__phpunit_invocationMocker;
|
||||
@@ -91,9 +88,12 @@ class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
|
||||
return $this->__phpunit_getInvocationMocker()->hasMatchers();
|
||||
}
|
||||
|
||||
public function __phpunit_verify()
|
||||
public function __phpunit_verify($unsetInvocationMocker = true)
|
||||
{
|
||||
$this->__phpunit_getInvocationMocker()->verify();
|
||||
$this->__phpunit_invocationMocker = NULL;
|
||||
|
||||
if ($unsetInvocationMocker) {
|
||||
$this->__phpunit_invocationMocker = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch')
|
||||
\PHPUnit\Framework\MockObject\Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch')
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
|
||||
@@ -8,11 +8,11 @@ if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
|
||||
<?php
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
print $generator->generateClassFromWsdl(
|
||||
dirname(dirname(__FILE__)) . '/_fixture/GoogleSearch.wsdl',
|
||||
'GoogleSearch'
|
||||
__DIR__ . '/../_fixture/GoogleSearch.wsdl',
|
||||
'GoogleSearch'
|
||||
);
|
||||
?>
|
||||
--EXPECTF--
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch')
|
||||
\PHPUnit\Framework\MockObject\Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch')
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
|
||||
@@ -8,11 +8,11 @@ if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
|
||||
<?php
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
print $generator->generateClassFromWsdl(
|
||||
dirname(dirname(__FILE__)) . '/_fixture/GoogleSearch.wsdl',
|
||||
'My\\Space\\GoogleSearch'
|
||||
__DIR__ . '/../_fixture/GoogleSearch.wsdl',
|
||||
'My\\Space\\GoogleSearch'
|
||||
);
|
||||
?>
|
||||
--EXPECTF--
|
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch', array('doGoogleSearch'))
|
||||
\PHPUnit\Framework\MockObject\Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch', array('doGoogleSearch'))
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
|
||||
@@ -8,12 +8,12 @@ if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
|
||||
<?php
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$generator = new \PHPUnit\Framework\MockObject\Generator;
|
||||
|
||||
print $generator->generateClassFromWsdl(
|
||||
dirname(dirname(__FILE__)) . '/_fixture/GoogleSearch.wsdl',
|
||||
'GoogleSearch',
|
||||
array('doGoogleSearch')
|
||||
__DIR__ . '/../_fixture/GoogleSearch.wsdl',
|
||||
'GoogleSearch',
|
||||
array('doGoogleSearch')
|
||||
);
|
||||
?>
|
||||
--EXPECTF--
|
@@ -1,87 +1,108 @@
|
||||
<?php
|
||||
class Framework_MockObject_GeneratorTest extends PHPUnit_Framework_TestCase
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\MockObject\Generator;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \PHPUnit\Framework\MockObject\Generator
|
||||
*
|
||||
* @uses \PHPUnit\Framework\MockObject\InvocationMocker
|
||||
* @uses \PHPUnit\Framework\MockObject\Builder\InvocationMocker
|
||||
* @uses \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation
|
||||
* @uses \PHPUnit\Framework\MockObject\Invocation\StaticInvocation
|
||||
* @uses \PHPUnit\Framework\MockObject\Matcher
|
||||
* @uses \PHPUnit\Framework\MockObject\Matcher\InvokedRecorder
|
||||
* @uses \PHPUnit\Framework\MockObject\Matcher\MethodName
|
||||
* @uses \PHPUnit\Framework\MockObject\Stub\ReturnStub
|
||||
* @uses \PHPUnit\Framework\MockObject\Matcher\InvokedCount
|
||||
*/
|
||||
class GeneratorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var PHPUnit_Framework_MockObject_Generator
|
||||
* @var Generator
|
||||
*/
|
||||
protected $generator;
|
||||
private $generator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->generator = new PHPUnit_Framework_MockObject_Generator;
|
||||
$this->generator = new Generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_MockObject_Generator::getMock
|
||||
* @expectedException PHPUnit_Framework_Exception
|
||||
*/
|
||||
public function testGetMockFailsWhenInvalidFunctionNameIsPassedInAsAFunctionToMock()
|
||||
{
|
||||
$this->generator->getMock('StdClass', array(0));
|
||||
$this->expectException(\PHPUnit\Framework\MockObject\RuntimeException::class);
|
||||
|
||||
$this->generator->getMock(stdClass::class, [0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_MockObject_Generator::getMock
|
||||
*/
|
||||
public function testGetMockCanCreateNonExistingFunctions()
|
||||
{
|
||||
$mock = $this->generator->getMock('StdClass', array('testFunction'));
|
||||
$mock = $this->generator->getMock(stdClass::class, ['testFunction']);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'testFunction'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_MockObject_Generator::getMock
|
||||
* @expectedException PHPUnit_Framework_MockObject_RuntimeException
|
||||
* @expectedExceptionMessage duplicates: "foo, foo"
|
||||
*/
|
||||
public function testGetMockGeneratorFails()
|
||||
{
|
||||
$mock = $this->generator->getMock('StdClass', array('foo', 'foo'));
|
||||
$this->expectException(\PHPUnit\Framework\MockObject\RuntimeException::class);
|
||||
$this->expectExceptionMessage('duplicates: "foo, bar, foo" (duplicate: "foo")');
|
||||
|
||||
$this->generator->getMock(stdClass::class, ['foo', 'bar', 'foo']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
|
||||
* @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');
|
||||
$mock = $this->generator->getMockForAbstractClass(Countable::class);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
|
||||
*/
|
||||
public function testGetMockForAbstractClassStubbingAbstractClass()
|
||||
{
|
||||
$mock = $this->generator->getMockForAbstractClass('AbstractMockTestClass');
|
||||
$mock = $this->generator->getMockForAbstractClass(AbstractMockTestClass::class);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'doSomething'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
|
||||
*/
|
||||
public function testGetMockForAbstractClassWithNonExistentMethods()
|
||||
{
|
||||
$mock = $this->generator->getMockForAbstractClass(
|
||||
'AbstractMockTestClass',
|
||||
array(),
|
||||
AbstractMockTestClass::class,
|
||||
[],
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
array('nonexistentMethod')
|
||||
['nonexistentMethod']
|
||||
);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'nonexistentMethod'));
|
||||
$this->assertTrue(method_exists($mock, 'doSomething'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
|
||||
*/
|
||||
public function testGetMockForAbstractClassShouldCreateStubsOnlyForAbstractMethodWhenNoMethodsWereInformed()
|
||||
{
|
||||
$mock = $this->generator->getMockForAbstractClass('AbstractMockTestClass');
|
||||
$mock = $this->generator->getMockForAbstractClass(AbstractMockTestClass::class);
|
||||
|
||||
$mock->expects($this->any())
|
||||
->method('doSomething')
|
||||
@@ -93,48 +114,39 @@ class Framework_MockObject_GeneratorTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider
|
||||
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
|
||||
* @expectedException PHPUnit_Framework_Exception
|
||||
*/
|
||||
public function testGetMockForAbstractClassExpectingInvalidArgumentException($className, $mockClassName)
|
||||
{
|
||||
$mock = $this->generator->getMockForAbstractClass($className, array(), $mockClassName);
|
||||
$this->expectException(PHPUnit\Framework\Exception::class);
|
||||
|
||||
$this->generator->getMockForAbstractClass($className, [], $mockClassName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
|
||||
* @expectedException PHPUnit_Framework_MockObject_RuntimeException
|
||||
*/
|
||||
public function testGetMockForAbstractClassAbstractClassDoesNotExist()
|
||||
{
|
||||
$mock = $this->generator->getMockForAbstractClass('Tux');
|
||||
$this->expectException(\PHPUnit\Framework\MockObject\RuntimeException::class);
|
||||
|
||||
$this->generator->getMockForAbstractClass('Tux');
|
||||
}
|
||||
|
||||
/**
|
||||
* Dataprovider for test "testGetMockForAbstractClassExpectingInvalidArgumentException"
|
||||
*/
|
||||
public static function getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider()
|
||||
public function getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider()
|
||||
{
|
||||
return array(
|
||||
'className not a string' => array(array(), ''),
|
||||
'mockClassName not a string' => array('Countable', new StdClass),
|
||||
);
|
||||
return [
|
||||
'className not a string' => [[], ''],
|
||||
'mockClassName not a string' => [Countable::class, new stdClass],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_MockObject_Generator::getMockForTrait
|
||||
* @requires PHP 5.4.0
|
||||
*/
|
||||
public function testGetMockForTraitWithNonExistentMethodsAndNonAbstractMethods()
|
||||
{
|
||||
$mock = $this->generator->getMockForTrait(
|
||||
'AbstractTrait',
|
||||
array(),
|
||||
AbstractTrait::class,
|
||||
[],
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
array('nonexistentMethod')
|
||||
['nonexistentMethod']
|
||||
);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'nonexistentMethod'));
|
||||
@@ -143,58 +155,56 @@ class Framework_MockObject_GeneratorTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($mock->anotherMockableMethod());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPUnit_Framework_MockObject_Generator::getMockForTrait
|
||||
* @requires PHP 5.4.0
|
||||
*/
|
||||
public function testGetMockForTraitStubbingAbstractMethod()
|
||||
{
|
||||
$mock = $this->generator->getMockForTrait('AbstractTrait');
|
||||
$mock = $this->generator->getMockForTrait(AbstractTrait::class);
|
||||
|
||||
$this->assertTrue(method_exists($mock, 'doSomething'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 5.4.0
|
||||
*/
|
||||
public function testGetMockForSingletonWithReflectionSuccess()
|
||||
{
|
||||
// Probably, this should be moved to tests/autoload.php
|
||||
require_once __DIR__ . '/_fixture/SingletonClass.php';
|
||||
$mock = $this->generator->getMock(SingletonClass::class, ['doSomething'], [], '', false);
|
||||
|
||||
$mock = $this->generator->getMock('SingletonClass', array('doSomething'), array(), '', false);
|
||||
$this->assertInstanceOf('SingletonClass', $mock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as "testGetMockForSingletonWithReflectionSuccess", but we expect
|
||||
* warning for PHP < 5.4.0 since PHPUnit will try to execute private __wakeup
|
||||
* on unserialize
|
||||
*/
|
||||
public function testGetMockForSingletonWithUnserializeFail()
|
||||
public function testExceptionIsRaisedForMutuallyExclusiveOptions()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
|
||||
$this->markTestSkipped('Only for PHP < 5.4.0');
|
||||
}
|
||||
$this->expectException(\PHPUnit\Framework\MockObject\RuntimeException::class);
|
||||
|
||||
$this->setExpectedException('PHPUnit_Framework_MockObject_RuntimeException');
|
||||
|
||||
// Probably, this should be moved to tests/autoload.php
|
||||
require_once __DIR__ . '/_fixture/SingletonClass.php';
|
||||
|
||||
$mock = $this->generator->getMock('SingletonClass', array('doSomething'), array(), '', false);
|
||||
$this->generator->getMock(stdClass::class, [], [], '', false, true, true, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* ReflectionClass::getMethods for SoapClient on PHP 5.3 produces PHP Fatal Error
|
||||
* @runInSeparateProcess
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testGetMockForSoapClientReflectionMethodsDuplication()
|
||||
public function testCanImplementInterfacesThatHaveMethodsWithReturnTypes()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
|
||||
$this->markTestSkipped('Only for PHP < 5.4.0');
|
||||
}
|
||||
$stub = $this->generator->getMock([AnInterfaceWithReturnType::class, AnInterface::class]);
|
||||
|
||||
$mock = $this->generator->getMock('SoapClient', array(), array(), '', false);
|
||||
$this->assertInstanceOf('SoapClient', $mock);
|
||||
$this->assertInstanceOf(AnInterfaceWithReturnType::class, $stub);
|
||||
$this->assertInstanceOf(AnInterface::class, $stub);
|
||||
$this->assertInstanceOf(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());
|
||||
}
|
||||
}
|
||||
|
120
vendor/phpunit/phpunit-mock-objects/tests/Invocation/ObjectInvocationTest.php
vendored
Normal file
120
vendor/phpunit/phpunit-mock-objects/tests/Invocation/ObjectInvocationTest.php
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\MockObject\Invocation\ObjectInvocation;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ObjectInvocationTest extends TestCase
|
||||
{
|
||||
public function testConstructorRequiresClassAndMethodAndParametersAndObject()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
ObjectInvocation::class,
|
||||
new ObjectInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
['an_argument'],
|
||||
'ReturnType',
|
||||
new stdClass
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testAllowToGetClassNameSetInConstructor()
|
||||
{
|
||||
$invocation = new ObjectInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
['an_argument'],
|
||||
'ReturnType',
|
||||
new stdClass
|
||||
);
|
||||
|
||||
$this->assertSame('FooClass', $invocation->getClassName());
|
||||
}
|
||||
|
||||
public function testAllowToGetMethodNameSetInConstructor()
|
||||
{
|
||||
$invocation = new ObjectInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
['an_argument'],
|
||||
'ReturnType',
|
||||
new stdClass
|
||||
);
|
||||
|
||||
$this->assertSame('FooMethod', $invocation->getMethodName());
|
||||
}
|
||||
|
||||
public function testAllowToGetObjectSetInConstructor()
|
||||
{
|
||||
$expectedObject = new stdClass;
|
||||
|
||||
$invocation = new ObjectInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
['an_argument'],
|
||||
'ReturnType',
|
||||
$expectedObject
|
||||
);
|
||||
|
||||
$this->assertSame($expectedObject, $invocation->getObject());
|
||||
}
|
||||
|
||||
public function testAllowToGetMethodParametersSetInConstructor()
|
||||
{
|
||||
$expectedParameters = [
|
||||
'foo', 5, ['a', 'b'], new stdClass, null, false
|
||||
];
|
||||
|
||||
$invocation = new ObjectInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
$expectedParameters,
|
||||
'ReturnType',
|
||||
new stdClass
|
||||
);
|
||||
|
||||
$this->assertSame($expectedParameters, $invocation->getParameters());
|
||||
}
|
||||
|
||||
public function testConstructorAllowToSetFlagCloneObjectsInParameters()
|
||||
{
|
||||
$parameters = [new stdClass];
|
||||
$cloneObjects = true;
|
||||
|
||||
$invocation = new ObjectInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
$parameters,
|
||||
'ReturnType',
|
||||
new stdClass,
|
||||
$cloneObjects
|
||||
);
|
||||
|
||||
$this->assertEquals($parameters, $invocation->getParameters());
|
||||
$this->assertNotSame($parameters, $invocation->getParameters());
|
||||
}
|
||||
|
||||
public function testAllowToGetReturnTypeSetInConstructor()
|
||||
{
|
||||
$expectedReturnType = 'string';
|
||||
|
||||
$invocation = new ObjectInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
['an_argument'],
|
||||
$expectedReturnType,
|
||||
new stdClass
|
||||
);
|
||||
|
||||
$this->assertSame($expectedReturnType, $invocation->getReturnType());
|
||||
}
|
||||
}
|
99
vendor/phpunit/phpunit-mock-objects/tests/Invocation/StaticInvocationTest.php
vendored
Normal file
99
vendor/phpunit/phpunit-mock-objects/tests/Invocation/StaticInvocationTest.php
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\MockObject\Invocation\StaticInvocation;
|
||||
|
||||
class StaticInvocationTest extends TestCase
|
||||
{
|
||||
public function testConstructorRequiresClassAndMethodAndParameters()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
StaticInvocation::class,
|
||||
new StaticInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
['an_argument'],
|
||||
'ReturnType'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testAllowToGetClassNameSetInConstructor()
|
||||
{
|
||||
$invocation = new StaticInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
['an_argument'],
|
||||
'ReturnType'
|
||||
);
|
||||
|
||||
$this->assertSame('FooClass', $invocation->getClassName());
|
||||
}
|
||||
|
||||
public function testAllowToGetMethodNameSetInConstructor()
|
||||
{
|
||||
$invocation = new StaticInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
['an_argument'],
|
||||
'ReturnType'
|
||||
);
|
||||
|
||||
$this->assertSame('FooMethod', $invocation->getMethodName());
|
||||
}
|
||||
|
||||
public function testAllowToGetMethodParametersSetInConstructor()
|
||||
{
|
||||
$expectedParameters = [
|
||||
'foo', 5, ['a', 'b'], new stdClass, null, false
|
||||
];
|
||||
|
||||
$invocation = new StaticInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
$expectedParameters,
|
||||
'ReturnType'
|
||||
);
|
||||
|
||||
$this->assertSame($expectedParameters, $invocation->getParameters());
|
||||
}
|
||||
|
||||
public function testConstructorAllowToSetFlagCloneObjectsInParameters()
|
||||
{
|
||||
$parameters = [new stdClass];
|
||||
$cloneObjects = true;
|
||||
|
||||
$invocation = new StaticInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
$parameters,
|
||||
'ReturnType',
|
||||
$cloneObjects
|
||||
);
|
||||
|
||||
$this->assertEquals($parameters, $invocation->getParameters());
|
||||
$this->assertNotSame($parameters, $invocation->getParameters());
|
||||
}
|
||||
|
||||
public function testAllowToGetReturnTypeSetInConstructor()
|
||||
{
|
||||
$expectedReturnType = 'string';
|
||||
|
||||
$invocation = new StaticInvocation(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
['an_argument'],
|
||||
$expectedReturnType
|
||||
);
|
||||
|
||||
$this->assertSame($expectedReturnType, $invocation->getReturnType());
|
||||
}
|
||||
}
|
68
vendor/phpunit/phpunit-mock-objects/tests/Matcher/ConsecutiveParametersTest.php
vendored
Normal file
68
vendor/phpunit/phpunit-mock-objects/tests/Matcher/ConsecutiveParametersTest.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the phpunit-mock-objects 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.
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
class ConsecutiveParametersTest extends 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(ExpectationFailedException::class);
|
||||
|
||||
$mock->foo('invalid');
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -8,100 +8,122 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since File available since Release 1.0.0
|
||||
*/
|
||||
class Framework_MockBuilderTest extends PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\MockObject\MockBuilder;
|
||||
|
||||
class MockBuilderTest extends TestCase
|
||||
{
|
||||
public function testMockBuilderRequiresClassName()
|
||||
{
|
||||
$spec = $this->getMockBuilder('Mockable');
|
||||
$mock = $spec->getMock();
|
||||
$mock = $this->getMockBuilder(Mockable::class)->getMock();
|
||||
|
||||
$this->assertTrue($mock instanceof Mockable);
|
||||
}
|
||||
|
||||
public function testByDefaultMocksAllMethods()
|
||||
{
|
||||
$spec = $this->getMockBuilder('Mockable');
|
||||
$mock = $spec->getMock();
|
||||
$mock = $this->getMockBuilder(Mockable::class)->getMock();
|
||||
|
||||
$this->assertNull($mock->mockableMethod());
|
||||
$this->assertNull($mock->anotherMockableMethod());
|
||||
}
|
||||
|
||||
public function testMethodsToMockCanBeSpecified()
|
||||
{
|
||||
$spec = $this->getMockBuilder('Mockable');
|
||||
$spec->setMethods(array('mockableMethod'));
|
||||
$mock = $spec->getMock();
|
||||
$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()
|
||||
{
|
||||
$spec = $this->getMockBuilder('Mockable');
|
||||
$mock = $spec->getMock();
|
||||
$this->assertEquals(array(null, null), $mock->constructorArgs);
|
||||
$mock = $this->getMockBuilder(Mockable::class)->getMock();
|
||||
|
||||
$this->assertEquals([null, null], $mock->constructorArgs);
|
||||
}
|
||||
|
||||
public function testMockClassNameCanBeSpecified()
|
||||
{
|
||||
$spec = $this->getMockBuilder('Mockable');
|
||||
$spec->setMockClassName('ACustomClassName');
|
||||
$mock = $spec->getMock();
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->setMockClassName('ACustomClassName')
|
||||
->getMock();
|
||||
|
||||
$this->assertTrue($mock instanceof ACustomClassName);
|
||||
}
|
||||
|
||||
public function testConstructorArgumentsCanBeSpecified()
|
||||
{
|
||||
$spec = $this->getMockBuilder('Mockable');
|
||||
$spec->setConstructorArgs($expected = array(23, 42));
|
||||
$mock = $spec->getMock();
|
||||
$this->assertEquals($expected, $mock->constructorArgs);
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->setConstructorArgs([23, 42])
|
||||
->getMock();
|
||||
|
||||
$this->assertEquals([23, 42], $mock->constructorArgs);
|
||||
}
|
||||
|
||||
public function testOriginalConstructorCanBeDisabled()
|
||||
{
|
||||
$spec = $this->getMockBuilder('Mockable');
|
||||
$spec->disableOriginalConstructor();
|
||||
$mock = $spec->getMock();
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->assertNull($mock->constructorArgs);
|
||||
}
|
||||
|
||||
public function testByDefaultOriginalCloneIsPreserved()
|
||||
{
|
||||
$spec = $this->getMockBuilder('Mockable');
|
||||
$mock = $spec->getMock();
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->getMock();
|
||||
|
||||
$cloned = clone $mock;
|
||||
|
||||
$this->assertTrue($cloned->cloned);
|
||||
}
|
||||
|
||||
public function testOriginalCloneCanBeDisabled()
|
||||
{
|
||||
$spec = $this->getMockBuilder('Mockable');
|
||||
$spec->disableOriginalClone();
|
||||
$mock = $spec->getMock();
|
||||
$mock->cloned = false;
|
||||
$cloned = clone $mock;
|
||||
$this->assertFalse($cloned->cloned);
|
||||
}
|
||||
$mock = $this->getMockBuilder(Mockable::class)
|
||||
->disableOriginalClone()
|
||||
->getMock();
|
||||
|
||||
public function testCallingAutoloadCanBeDisabled()
|
||||
{
|
||||
// it is not clear to me how to test this nor the difference
|
||||
// between calling it or not
|
||||
$this->markTestIncomplete();
|
||||
$mock->cloned = false;
|
||||
$cloned = clone $mock;
|
||||
|
||||
$this->assertFalse($cloned->cloned);
|
||||
}
|
||||
|
||||
public function testProvidesAFluentInterface()
|
||||
{
|
||||
$spec = $this->getMockBuilder('Mockable')
|
||||
->setMethods(array('mockableMethod'))
|
||||
->setConstructorArgs(array())
|
||||
$spec = $this->getMockBuilder(Mockable::class)
|
||||
->setMethods(['mockableMethod'])
|
||||
->setConstructorArgs([])
|
||||
->setMockClassName('DummyClassName')
|
||||
->disableOriginalConstructor()
|
||||
->disableOriginalClone()
|
||||
->disableAutoload();
|
||||
$this->assertTrue($spec instanceof PHPUnit_Framework_MockObject_MockBuilder);
|
||||
|
||||
$this->assertTrue($spec instanceof MockBuilder);
|
||||
}
|
||||
}
|
||||
|
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Framework_MockObject_Invocation_ObjectTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstructorRequiresClassAndMethodAndParametersAndObject()
|
||||
{
|
||||
new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
array('an_argument'),
|
||||
new StdClass
|
||||
);
|
||||
}
|
||||
|
||||
public function testAllowToGetClassNameSetInConstructor()
|
||||
{
|
||||
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
array('an_argument'),
|
||||
new StdClass
|
||||
);
|
||||
|
||||
$this->assertSame('FooClass', $invocation->className);
|
||||
}
|
||||
|
||||
public function testAllowToGetMethodNameSetInConstructor()
|
||||
{
|
||||
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
array('an_argument'),
|
||||
new StdClass
|
||||
);
|
||||
|
||||
$this->assertSame('FooMethod', $invocation->methodName);
|
||||
}
|
||||
|
||||
public function testAllowToGetObjectSetInConstructor()
|
||||
{
|
||||
$expectedObject = new StdClass;
|
||||
|
||||
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
array('an_argument'),
|
||||
$expectedObject
|
||||
);
|
||||
|
||||
$this->assertSame($expectedObject, $invocation->object);
|
||||
}
|
||||
|
||||
public function testAllowToGetMethodParametersSetInConstructor()
|
||||
{
|
||||
$expectedParameters = array(
|
||||
'foo', 5, array('a', 'b'), new StdClass, null, false
|
||||
);
|
||||
|
||||
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
$expectedParameters,
|
||||
new StdClass
|
||||
);
|
||||
|
||||
$this->assertSame($expectedParameters, $invocation->parameters);
|
||||
}
|
||||
|
||||
public function testConstructorAllowToSetFlagCloneObjectsInParameters()
|
||||
{
|
||||
$parameters = array(new StdClass);
|
||||
$cloneObjects = true;
|
||||
|
||||
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
$parameters,
|
||||
new StdClass,
|
||||
$cloneObjects
|
||||
);
|
||||
|
||||
$this->assertEquals($parameters, $invocation->parameters);
|
||||
$this->assertNotSame($parameters, $invocation->parameters);
|
||||
}
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Framework_MockObject_Invocation_StaticTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstructorRequiresClassAndMethodAndParameters()
|
||||
{
|
||||
new PHPUnit_Framework_MockObject_Invocation_Static('FooClass', 'FooMethod', array('an_argument'));
|
||||
}
|
||||
|
||||
public function testAllowToGetClassNameSetInConstructor()
|
||||
{
|
||||
$invocation = new PHPUnit_Framework_MockObject_Invocation_Static('FooClass', 'FooMethod', array('an_argument'));
|
||||
|
||||
$this->assertSame('FooClass', $invocation->className);
|
||||
}
|
||||
|
||||
public function testAllowToGetMethodNameSetInConstructor()
|
||||
{
|
||||
$invocation = new PHPUnit_Framework_MockObject_Invocation_Static('FooClass', 'FooMethod', array('an_argument'));
|
||||
|
||||
$this->assertSame('FooMethod', $invocation->methodName);
|
||||
}
|
||||
|
||||
public function testAllowToGetMethodParametersSetInConstructor()
|
||||
{
|
||||
$expectedParameters = array(
|
||||
'foo', 5, array('a', 'b'), new StdClass, null, false
|
||||
);
|
||||
|
||||
$invocation = new PHPUnit_Framework_MockObject_Invocation_Static(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
$expectedParameters
|
||||
);
|
||||
|
||||
$this->assertSame($expectedParameters, $invocation->parameters);
|
||||
}
|
||||
|
||||
public function testConstructorAllowToSetFlagCloneObjectsInParameters()
|
||||
{
|
||||
$parameters = array(new StdClass);
|
||||
$cloneObjects = true;
|
||||
|
||||
$invocation = new PHPUnit_Framework_MockObject_Invocation_Static(
|
||||
'FooClass',
|
||||
'FooMethod',
|
||||
$parameters,
|
||||
$cloneObjects
|
||||
);
|
||||
|
||||
$this->assertEquals($parameters, $invocation->parameters);
|
||||
$this->assertNotSame($parameters, $invocation->parameters);
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
class Framework_MockObject_Matcher_ConsecutiveParametersTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIntegration()
|
||||
{
|
||||
$mock = $this->getMock('stdClass', array('foo'));
|
||||
$mock
|
||||
->expects($this->any())
|
||||
->method('foo')
|
||||
->withConsecutive(
|
||||
array('bar'),
|
||||
array(21, 42)
|
||||
);
|
||||
$mock->foo('bar');
|
||||
$mock->foo(21, 42);
|
||||
}
|
||||
|
||||
public function testIntegrationWithLessAssertionsThenMethodCalls()
|
||||
{
|
||||
$mock = $this->getMock('stdClass', array('foo'));
|
||||
$mock
|
||||
->expects($this->any())
|
||||
->method('foo')
|
||||
->withConsecutive(
|
||||
array('bar')
|
||||
);
|
||||
$mock->foo('bar');
|
||||
$mock->foo(21, 42);
|
||||
}
|
||||
|
||||
public function testIntegrationExpectingException()
|
||||
{
|
||||
$mock = $this->getMock('stdClass', array('foo'));
|
||||
$mock
|
||||
->expects($this->any())
|
||||
->method('foo')
|
||||
->withConsecutive(
|
||||
array('bar'),
|
||||
array(21, 42)
|
||||
);
|
||||
$mock->foo('bar');
|
||||
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
|
||||
$mock->foo('invalid');
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHPUnit_MockObject package.
|
||||
* This file is part of the phpunit-mock-objects package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -8,14 +8,13 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since Class available since Release 2.0.0
|
||||
*/
|
||||
class Framework_ProxyObjectTest extends PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ProxyObjectTest extends TestCase
|
||||
{
|
||||
public function testMockedMethodIsProxiedToOriginalMethod()
|
||||
{
|
||||
$proxy = $this->getMockBuilder('Bar')
|
||||
$proxy = $this->getMockBuilder(Bar::class)
|
||||
->enableProxyingToOriginalMethods()
|
||||
->getMock();
|
||||
|
||||
@@ -23,14 +22,16 @@ class Framework_ProxyObjectTest extends PHPUnit_Framework_TestCase
|
||||
->method('doSomethingElse');
|
||||
|
||||
$foo = new Foo;
|
||||
|
||||
$this->assertEquals('result', $foo->doSomething($proxy));
|
||||
}
|
||||
|
||||
public function testMockedMethodWithReferenceIsProxiedToOriginalMethod()
|
||||
{
|
||||
$proxy = $this->getMockBuilder('MethodCallbackByReference')
|
||||
$proxy = $this->getMockBuilder(MethodCallbackByReference::class)
|
||||
->enableProxyingToOriginalMethods()
|
||||
->getMock();
|
||||
|
||||
$a = $b = $c = 0;
|
||||
|
||||
$proxy->callback($a, $b, $c);
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
interface AnInterface
|
||||
{
|
||||
public function doSomething();
|
||||
|
5
vendor/phpunit/phpunit-mock-objects/tests/_fixture/AnInterfaceWithReturnType.php
vendored
Normal file
5
vendor/phpunit/phpunit-mock-objects/tests/_fixture/AnInterfaceWithReturnType.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
interface AnInterfaceWithReturnType
|
||||
{
|
||||
public function returnAnArray(): array;
|
||||
}
|
56
vendor/phpunit/phpunit-mock-objects/tests/_fixture/ClassWithAllPossibleReturnTypes.php
vendored
Normal file
56
vendor/phpunit/phpunit-mock-objects/tests/_fixture/ClassWithAllPossibleReturnTypes.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
class ClassWithAllPossibleReturnTypes
|
||||
{
|
||||
public function methodWithNoReturnTypeDeclaration()
|
||||
{
|
||||
}
|
||||
|
||||
public function methodWithVoidReturnTypeDeclaration(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function methodWithStringReturnTypeDeclaration(): string
|
||||
{
|
||||
return 'string';
|
||||
}
|
||||
|
||||
public function methodWithFloatReturnTypeDeclaration(): float
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
public function methodWithIntReturnTypeDeclaration(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function methodWithBoolReturnTypeDeclaration(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function methodWithArrayReturnTypeDeclaration(): array
|
||||
{
|
||||
return ['string'];
|
||||
}
|
||||
|
||||
public function methodWithTraversableReturnTypeDeclaration(): Traversable
|
||||
{
|
||||
return new ArrayIterator(['string']);
|
||||
}
|
||||
|
||||
public function methodWithGeneratorReturnTypeDeclaration(): Generator
|
||||
{
|
||||
yield 1;
|
||||
}
|
||||
|
||||
public function methodWithObjectReturnTypeDeclaration(): object
|
||||
{
|
||||
return new Exception;
|
||||
}
|
||||
|
||||
public function methodWithClassReturnTypeDeclaration(): stdClass
|
||||
{
|
||||
return new stdClass;
|
||||
}
|
||||
}
|
7
vendor/phpunit/phpunit-mock-objects/tests/_fixture/ClassWithSelfTypeHint.php
vendored
Normal file
7
vendor/phpunit/phpunit-mock-objects/tests/_fixture/ClassWithSelfTypeHint.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
class ClassWithSelfTypeHint
|
||||
{
|
||||
public function foo(self $foo)
|
||||
{
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@ function functionCallback()
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
if ($args == array('foo', 'bar')) {
|
||||
if ($args == ['foo', 'bar']) {
|
||||
return 'pass';
|
||||
}
|
||||
}
|
||||
|
5
vendor/phpunit/phpunit-mock-objects/tests/_fixture/InterfaceWithSemiReservedMethodName.php
vendored
Normal file
5
vendor/phpunit/phpunit-mock-objects/tests/_fixture/InterfaceWithSemiReservedMethodName.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
interface InterfaceWithSemiReservedMethodName
|
||||
{
|
||||
public function unset();
|
||||
}
|
@@ -5,7 +5,7 @@ class MethodCallback
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
if ($args == array('foo', 'bar')) {
|
||||
if ($args == ['foo', 'bar']) {
|
||||
return 'pass';
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class MethodCallback
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
if ($args == array('foo', 'bar')) {
|
||||
if ($args == ['foo', 'bar']) {
|
||||
return 'pass';
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ class Mockable
|
||||
|
||||
public function __construct($arg1 = null, $arg2 = null)
|
||||
{
|
||||
$this->constructorArgs = array($arg1, $arg2);
|
||||
$this->constructorArgs = [$arg1, $arg2];
|
||||
}
|
||||
|
||||
public function mockableMethod()
|
||||
|
@@ -3,11 +3,11 @@ class SomeClass
|
||||
{
|
||||
public function doSomething($a, $b)
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
public function doSomethingElse($c)
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
8
vendor/phpunit/phpunit-mock-objects/tests/_fixture/StringableClass.php
vendored
Normal file
8
vendor/phpunit/phpunit-mock-objects/tests/_fixture/StringableClass.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
class StringableClass
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return '12345';
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
interface TraversableMockTestInterface extends Traversable
|
||||
|
||||
interface TraversableMockTestInterface extends \Traversable
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user