Upgrade to KH 3.3.0

This commit is contained in:
Deon George
2012-11-22 14:25:06 +11:00
parent e5e67a59bb
commit 5bd1841571
1455 changed files with 114353 additions and 9466 deletions

View File

@@ -0,0 +1,89 @@
<?php
class Framework_MockObject_GeneratorTest extends PHPUnit_Framework_TestCase
{
/**
* @covers PHPUnit_Framework_MockObject_Generator::getMock
* @expectedException PHPUnit_Framework_Exception
*/
public function testGetMockFailsWhenInvalidFunctionNameIsPassedInAsAFunctionToMock()
{
PHPUnit_Framework_MockObject_Generator::getMock('StdClass', array(0));
}
/**
* @covers PHPUnit_Framework_MockObject_Generator::getMock
*/
public function testGetMockCanCreateNonExistingFunctions()
{
$mock = PHPUnit_Framework_MockObject_Generator::getMock('StdClass', array('testFunction'));
$this->assertTrue(method_exists($mock, 'testFunction'));
}
/**
* @covers PHPUnit_Framework_MockObject_Generator::getMock
* @expectedException PHPUnit_Framework_Exception
* @expectedExceptionMessage duplicates: "foo, foo"
*/
public function testGetMockGeneratorFails()
{
$mock = PHPUnit_Framework_MockObject_Generator::getMock('StdClass', array('foo', 'foo'));
}
/**
* @covers PHPUnit_Framework_MockObject_Generator::getObject
*/
public function testMockObjectHasUniqueIdSoThatTwoMockObjectsOfTheSameClassAreNotEqual()
{
$mock1 = PHPUnit_Framework_MockObject_Generator::getMock('stdClass');
$mock2 = PHPUnit_Framework_MockObject_Generator::getMock('stdClass');
$this->assertNotEquals($mock1, $mock2);
}
/**
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
*/
public function testGetMockForAbstractClassDoesNotFailWhenFakingInterfaces()
{
$mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass('Countable');
$this->assertTrue(method_exists($mock, 'count'));
}
/**
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
*/
public function testGetMockForAbstractClassStubbingAbstractClass()
{
$mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass('AbstractMockTestClass');
$this->assertTrue(method_exists($mock, 'doSomething'));
}
/**
* @dataProvider getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
* @expectedException PHPUnit_Framework_Exception
*/
public function testGetMockForAbstractClassExpectingInvalidArgumentException($className, $mockClassName)
{
$mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass($className, array(), $mockClassName);
}
/**
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
* @expectedException PHPUnit_Framework_Exception
*/
public function testGetMockForAbstractClassAnstractClassDoesNotExist()
{
$mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass('Tux');
}
/**
* Dataprovider for test "testGetMockForAbstractClassExpectingInvalidArgumentException"
*/
public static function getMockForAbstractClassExpectsInvalidArgumentExceptionDataprovider()
{
return array(
'className not a string' => array(array(), ''),
'mockClassName not a string' => array('Countable', new StdClass),
);
}
}

View File

@@ -0,0 +1,152 @@
<?php
/**
* PHPUnit
*
* Copyright (c) 2010-2012, Sebastian Bergmann <sb@sebastian-bergmann.de>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Sebastian Bergmann nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package PHPUnit_MockObject
* @author Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2010-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://github.com/sebastianbergmann/phpunit-mock-objects
* @since File available since Release 1.0.0
*/
require_once 'PHPUnit/Framework/TestCase.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Mockable.php';
/**
* @package PHPUnit_MockObject
* @author Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2010-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://github.com/sebastianbergmann/phpunit-mock-objects
* @since File available since Release 1.0.0
*/
class Framework_MockBuilderTest extends PHPUnit_Framework_TestCase
{
public function testMockBuilderRequiresClassName()
{
$spec = $this->getMockBuilder('Mockable');
$mock = $spec->getMock();
$this->assertTrue($mock instanceof Mockable);
}
public function testByDefaultMocksAllMethods()
{
$spec = $this->getMockBuilder('Mockable');
$mock = $spec->getMock();
$this->assertNull($mock->mockableMethod());
$this->assertNull($mock->anotherMockableMethod());
}
public function testMethodsToMockCanBeSpecified()
{
$spec = $this->getMockBuilder('Mockable');
$spec->setMethods(array('mockableMethod'));
$mock = $spec->getMock();
$this->assertNull($mock->mockableMethod());
$this->assertTrue($mock->anotherMockableMethod());
}
public function testByDefaultDoesNotPassArgumentsToTheConstructor()
{
$spec = $this->getMockBuilder('Mockable');
$mock = $spec->getMock();
$this->assertEquals(array(NULL, NULL), $mock->constructorArgs);
}
public function testMockClassNameCanBeSpecified()
{
$spec = $this->getMockBuilder('Mockable');
$spec->setMockClassName('ACustomClassName');
$mock = $spec->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);
}
public function testOriginalConstructorCanBeDisabled()
{
$spec = $this->getMockBuilder('Mockable');
$spec->disableOriginalConstructor();
$mock = $spec->getMock();
$this->assertNull($mock->constructorArgs);
}
public function testByDefaultOriginalCloneIsPreserved()
{
$spec = $this->getMockBuilder('Mockable');
$mock = $spec->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);
}
public function testCallingAutoloadCanBeDisabled()
{
// it is not clear to me how to test this nor the difference
// between calling it or not
$this->markTestIncomplete();
}
public function testProvidesAFluentInterface()
{
$spec = $this->getMockBuilder('Mockable')
->setMethods(array('mockableMethod'))
->setConstructorArgs(array())
->setMockClassName('DummyClassName')
->disableOriginalConstructor()
->disableOriginalClone()
->disableAutoload();
$this->assertTrue($spec instanceof PHPUnit_Framework_MockObject_MockBuilder);
}
}

View File

@@ -0,0 +1,82 @@
<?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);
}
}

View File

@@ -0,0 +1,52 @@
<?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);
}
}

View File

@@ -0,0 +1,137 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
--FILE--
<?php
class Foo
{
public function bar(Foo $foo)
{
}
public function baz(Foo $foo)
{
}
}
require_once 'PHPUnit/Autoload.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array(),
'MockFoo',
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function bar(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, $this, TRUE
)
);
return $result;
}
public function baz(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'baz', $arguments, $this, TRUE
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,91 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
--FILE--
<?php
class Foo
{
public function __clone()
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array(),
'MockFoo',
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
parent::__clone();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,90 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
--FILE--
<?php
class Foo
{
public function __construct()
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array(),
'MockFoo',
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,90 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', FALSE)
--FILE--
<?php
class Foo
{
public function __clone()
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array(),
'MockFoo',
FALSE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,90 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
--FILE--
<?php
class Foo
{
public function __construct()
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array(),
'MockFoo',
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,95 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
--FILE--
<?php
interface IFoo
{
public function __construct($bar);
}
class Foo implements IFoo
{
public function __construct($bar)
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array(),
'MockFoo',
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,95 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE)
--FILE--
<?php
interface IFoo
{
public function __construct($bar);
}
class Foo implements IFoo
{
public function __construct($bar)
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array(),
'MockFoo',
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,116 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array('bar'), 'MockFoo', TRUE, TRUE)
--FILE--
<?php
class Foo
{
public function bar(Foo $foo)
{
}
public function baz(Foo $foo)
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array('bar'),
'MockFoo',
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function bar(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, $this, TRUE
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,110 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
--FILE--
<?php
interface Foo
{
public function bar(Foo $foo);
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array(),
'MockFoo',
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, Foo
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function bar(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, $this, TRUE
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,139 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE, TRUE)
--FILE--
<?php
class Foo
{
public function bar(Foo $foo)
{
}
public function baz(Foo $foo)
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array(),
'MockFoo',
TRUE,
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function bar(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'bar', $arguments, $this, TRUE
)
);
return $result;
}
public function baz(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'Foo', 'baz', $arguments, $this, TRUE
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,139 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE, TRUE)
--FILE--
<?php
class Foo
{
public static function bar(Foo $foo)
{
}
public static function baz(Foo $foo)
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array(),
'MockFoo',
TRUE,
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public static function bar(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = self::__phpunit_getStaticInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Static(
'Foo', 'bar', $arguments, TRUE
)
);
return $result;
}
public static function baz(Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = self::__phpunit_getStaticInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Static(
'Foo', 'baz', $arguments, TRUE
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,140 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE, TRUE)
--FILE--
<?php
namespace NS;
class Foo
{
public function bar(Foo $foo)
{
}
public function baz(Foo $foo)
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = \PHPUnit_Framework_MockObject_Generator::generate(
'NS\Foo',
array(),
'MockFoo',
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function bar(NS\Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'NS\Foo', 'bar', $arguments, $this, TRUE
)
);
return $result;
}
public function baz(NS\Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'NS\Foo', 'baz', $arguments, $this, TRUE
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,93 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
--FILE--
<?php
namespace NS;
class Foo
{
public function __clone()
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = \PHPUnit_Framework_MockObject_Generator::generate(
'NS\Foo',
array(),
'MockFoo',
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
parent::__clone();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,92 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
--FILE--
<?php
namespace NS;
class Foo
{
public function __construct()
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = \PHPUnit_Framework_MockObject_Generator::generate(
'NS\Foo',
array(),
'MockFoo',
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,92 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', FALSE)
--FILE--
<?php
namespace NS;
class Foo
{
public function __clone()
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = \PHPUnit_Framework_MockObject_Generator::generate(
'NS\Foo',
array(),
'MockFoo',
FALSE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,92 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
--FILE--
<?php
namespace NS;
class Foo
{
public function __construct()
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = \PHPUnit_Framework_MockObject_Generator::generate(
'NS\Foo',
array(),
'MockFoo',
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,97 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
--FILE--
<?php
namespace NS;
interface IFoo
{
public function __construct($bar);
}
class Foo implements IFoo
{
public function __construct($bar)
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = \PHPUnit_Framework_MockObject_Generator::generate(
'NS\Foo',
array(),
'MockFoo',
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,97 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE)
--FILE--
<?php
namespace NS;
interface IFoo
{
public function __construct($bar);
}
class Foo implements IFoo
{
public function __construct($bar)
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = \PHPUnit_Framework_MockObject_Generator::generate(
'NS\Foo',
array(),
'MockFoo',
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,118 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array('bar'), 'MockFoo', TRUE, TRUE)
--FILE--
<?php
namespace NS;
class Foo
{
public function bar(Foo $foo)
{
}
public function baz(Foo $foo)
{
}
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = \PHPUnit_Framework_MockObject_Generator::generate(
'NS\Foo',
array('bar'),
'MockFoo',
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function bar(NS\Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'NS\Foo', 'bar', $arguments, $this, TRUE
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,112 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE, TRUE)
--FILE--
<?php
namespace NS;
interface Foo
{
public function bar(Foo $foo);
}
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = \PHPUnit_Framework_MockObject_Generator::generate(
'NS\Foo',
array(),
'MockFoo',
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class MockFoo implements PHPUnit_Framework_MockObject_MockObject, NS\Foo
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function bar(NS\Foo $foo)
{
$arguments = array($foo);
$count = func_num_args();
if ($count > 1) {
$_arguments = func_get_args();
for ($i = 1; $i < $count; $i++) {
$arguments[] = $_arguments[$i];
}
}
$result = $this->__phpunit_getInvocationMocker()->invoke(
new PHPUnit_Framework_MockObject_Invocation_Object(
'NS\Foo', 'bar', $arguments, $this, TRUE
)
);
return $result;
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,87 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
--FILE--
<?php
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'Foo',
array(),
'MockFoo',
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
class Foo
{
}
class MockFoo extends Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}

View File

@@ -0,0 +1,95 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
--FILE--
<?php
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'NS\Foo',
array(),
'MockFoo',
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
namespace NS {
class Foo
{
}
}
namespace {
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}
}

View File

@@ -0,0 +1,95 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generate('Foo', array(), 'MockFoo', TRUE, TRUE)
--FILE--
<?php
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
$mock = PHPUnit_Framework_MockObject_Generator::generate(
'\NS\Foo',
array(),
'MockFoo',
TRUE,
TRUE
);
print $mock['code'];
?>
--EXPECTF--
namespace NS {
class Foo
{
}
}
namespace {
class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
{
private static $__phpunit_staticInvocationMocker;
private $__phpunit_invocationMocker;
private $__phpunit_id;
private static $__phpunit_nextId = 0;
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
$this->__phpunit_setId();
}
public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
public static function staticExpects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
{
return self::__phpunit_getStaticInvocationMocker()->expects($matcher);
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === NULL) {
$this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return $this->__phpunit_invocationMocker;
}
public static function __phpunit_getStaticInvocationMocker()
{
if (self::$__phpunit_staticInvocationMocker === NULL) {
self::$__phpunit_staticInvocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
}
return self::$__phpunit_staticInvocationMocker;
}
public function __phpunit_hasMatchers()
{
return self::__phpunit_getStaticInvocationMocker()->hasMatchers() ||
$this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify()
{
self::__phpunit_getStaticInvocationMocker()->verify();
$this->__phpunit_getInvocationMocker()->verify();
}
public function __phpunit_cleanup()
{
self::$__phpunit_staticInvocationMocker = NULL;
$this->__phpunit_invocationMocker = NULL;
$this->__phpunit_id = NULL;
}
public function __phpunit_setId()
{
$this->__phpunit_id = sprintf('%s#%s', get_class($this), self::$__phpunit_nextId++);
}
}
}

View File

@@ -0,0 +1,36 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch')
--SKIPIF--
<?php
if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
?>
--FILE--
<?php
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
print PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl(
dirname(dirname(__FILE__)) . '/_files/GoogleSearch.wsdl',
'GoogleSearch'
);
?>
--EXPECTF--
class GoogleSearch extends \SOAPClient
{
public function __construct($wsdl, array $options)
{
parent::__construct('%s/GoogleSearch.wsdl', $options);
}
public function doGetCachedPage($key, $url)
{
}
public function doSpellingSuggestion($key, $phrase)
{
}
public function doGoogleSearch($key, $q, $start, $maxResults, $filter, $restrict, $safeSearch, $lr, $ie, $oe)
{
}
}

View File

@@ -0,0 +1,38 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch')
--SKIPIF--
<?php
if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
?>
--FILE--
<?php
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
print PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl(
dirname(dirname(__FILE__)) . '/_files/GoogleSearch.wsdl',
'My\\Space\\GoogleSearch'
);
?>
--EXPECTF--
namespace My\Space;
class GoogleSearch extends \SOAPClient
{
public function __construct($wsdl, array $options)
{
parent::__construct('%s/GoogleSearch.wsdl', $options);
}
public function doGetCachedPage($key, $url)
{
}
public function doSpellingSuggestion($key, $phrase)
{
}
public function doGoogleSearch($key, $q, $start, $maxResults, $filter, $restrict, $safeSearch, $lr, $ie, $oe)
{
}
}

View File

@@ -0,0 +1,29 @@
--TEST--
PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl('GoogleSearch.wsdl', 'GoogleSearch', array('doGoogleSearch'))
--SKIPIF--
<?php
if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
?>
--FILE--
<?php
require_once 'PHPUnit/Autoload.php';
require_once 'Text/Template.php';
print PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl(
dirname(dirname(__FILE__)) . '/_files/GoogleSearch.wsdl',
'GoogleSearch',
array('doGoogleSearch')
);
?>
--EXPECTF--
class GoogleSearch extends \SOAPClient
{
public function __construct($wsdl, array $options)
{
parent::__construct('%s/GoogleSearch.wsdl', $options);
}
public function doGoogleSearch($key, $q, $start, $maxResults, $filter, $restrict, $safeSearch, $lr, $ie, $oe)
{
}
}

View File

@@ -0,0 +1,552 @@
<?php
/**
* PHPUnit
*
* Copyright (c) 2010-2012, Sebastian Bergmann <sb@sebastian-bergmann.de>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Sebastian Bergmann nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package PHPUnit_MockObject
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2010-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://www.phpunit.de/
* @since File available since Release 3.0.0
*/
require_once 'PHPUnit/Framework/TestCase.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'AbstractMockTestClass.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'AnInterface.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'FunctionCallback.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'MethodCallback.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'PartialMockTestClass.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'SomeClass.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'StaticMockTestClass.php';
/**
*
*
* @package PHPUnit_MockObject
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @author Patrick Mueller <elias0@gmx.net>
* @author Frank Kleine <mikey@stubbles.net>
* @copyright 2010-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @version Release: @package_version@
* @link http://www.phpunit.de/
* @since Class available since Release 3.0.0
*/
class Framework_MockObjectTest extends PHPUnit_Framework_TestCase
{
public function testMockedMethodIsNeverCalled()
{
$mock = $this->getMock('AnInterface');
$mock->expects($this->never())
->method('doSomething');
}
public function testMockedMethodIsNotCalledWhenExpectsAnyWithParameter()
{
$mock = $this->getMock('SomeClass');
$mock->expects($this->any())
->method('doSomethingElse')
->with('someArg');
}
public function testMockedMethodIsCalledAtLeastOnce()
{
$mock = $this->getMock('AnInterface');
$mock->expects($this->atLeastOnce())
->method('doSomething');
$mock->doSomething();
}
public function testMockedMethodIsCalledAtLeastOnce2()
{
$mock = $this->getMock('AnInterface');
$mock->expects($this->atLeastOnce())
->method('doSomething');
$mock->doSomething();
$mock->doSomething();
}
public function testMockedMethodIsCalledOnce()
{
$mock = $this->getMock('AnInterface');
$mock->expects($this->once())
->method('doSomething');
$mock->doSomething();
}
public function testMockedMethodIsCalledOnceWithParameter()
{
$mock = $this->getMock('SomeClass');
$mock->expects($this->once())
->method('doSomethingElse')
->with($this->equalTo('something'));
$mock->doSomethingElse('something');
}
public function testMockedMethodIsCalledExactly()
{
$mock = $this->getMock('AnInterface');
$mock->expects($this->exactly(2))
->method('doSomething');
$mock->doSomething();
$mock->doSomething();
}
public function testStubbedException()
{
$mock = $this->getMock('AnInterface');
$mock->expects($this->any())
->method('doSomething')
->will($this->throwException(new Exception));
try {
$mock->doSomething();
}
catch (Exception $e) {
return;
}
$this->fail();
}
public function testStubbedReturnValue()
{
$mock = $this->getMock('AnInterface');
$mock->expects($this->any())
->method('doSomething')
->will($this->returnValue('something'));
$this->assertEquals('something', $mock->doSomething());
}
public function testStubbedReturnValueMap()
{
$map = array(
array('a', 'b', 'c', 'd'),
array('e', 'f', 'g', 'h')
);
$mock = $this->getMock('AnInterface');
$mock->expects($this->any())
->method('doSomething')
->will($this->returnValueMap($map));
$this->assertEquals('d', $mock->doSomething('a', 'b', 'c'));
$this->assertEquals('h', $mock->doSomething('e', 'f', 'g'));
$this->assertEquals(NULL, $mock->doSomething('foo', 'bar'));
}
public function testFunctionCallback()
{
$mock = $this->getMock('SomeClass', array('doSomething'), array(), '', FALSE);
$mock->expects($this->once())
->method('doSomething')
->will($this->returnCallback('functionCallback'));
$this->assertEquals('pass', $mock->doSomething('foo', 'bar'));
}
public function testStaticMethodCallback()
{
$mock = $this->getMock('SomeClass', array('doSomething'), array(), '', FALSE);
$mock->expects($this->once())
->method('doSomething')
->will($this->returnCallback(array('MethodCallback', 'staticCallback')));
$this->assertEquals('pass', $mock->doSomething('foo', 'bar'));
}
public function testPublicMethodCallback()
{
$mock = $this->getMock('SomeClass', array('doSomething'), array(), '', FALSE);
$mock->expects($this->once())
->method('doSomething')
->will($this->returnCallback(array(new MethodCallback, 'nonStaticCallback')));
$this->assertEquals('pass', $mock->doSomething('foo', 'bar'));
}
public function testMockClassOnlyGeneratedOnce()
{
$mock1 = $this->getMock('AnInterface');
$mock2 = $this->getMock('AnInterface');
$this->assertEquals(get_class($mock1), get_class($mock2));
}
public function testMockClassDifferentForPartialMocks()
{
$mock1 = $this->getMock('PartialMockTestClass');
$mock2 = $this->getMock('PartialMockTestClass', array('doSomething'));
$mock3 = $this->getMock('PartialMockTestClass', array('doSomething'));
$mock4 = $this->getMock('PartialMockTestClass', array('doAnotherThing'));
$mock5 = $this->getMock('PartialMockTestClass', array('doAnotherThing'));
$this->assertNotEquals(get_class($mock1), get_class($mock2));
$this->assertNotEquals(get_class($mock1), get_class($mock3));
$this->assertNotEquals(get_class($mock1), get_class($mock4));
$this->assertNotEquals(get_class($mock1), get_class($mock5));
$this->assertEquals(get_class($mock2), get_class($mock3));
$this->assertNotEquals(get_class($mock2), get_class($mock4));
$this->assertNotEquals(get_class($mock2), get_class($mock5));
$this->assertEquals(get_class($mock4), get_class($mock5));
}
public function testMockClassStoreOverrulable()
{
$mock1 = $this->getMock('PartialMockTestClass');
$mock2 = $this->getMock('PartialMockTestClass', array(), array(), 'MyMockClassNameForPartialMockTestClass1');
$mock3 = $this->getMock('PartialMockTestClass');
$mock4 = $this->getMock('PartialMockTestClass', array('doSomething'), array(), 'AnotherMockClassNameForPartialMockTestClass');
$mock5 = $this->getMock('PartialMockTestClass', array(), array(), 'MyMockClassNameForPartialMockTestClass2');
$this->assertNotEquals(get_class($mock1), get_class($mock2));
$this->assertEquals(get_class($mock1), get_class($mock3));
$this->assertNotEquals(get_class($mock1), get_class($mock4));
$this->assertNotEquals(get_class($mock2), get_class($mock3));
$this->assertNotEquals(get_class($mock2), get_class($mock4));
$this->assertNotEquals(get_class($mock2), get_class($mock5));
$this->assertNotEquals(get_class($mock3), get_class($mock4));
$this->assertNotEquals(get_class($mock3), get_class($mock5));
$this->assertNotEquals(get_class($mock4), get_class($mock5));
}
/**
* @covers PHPUnit_Framework_MockObject_Generator::getMock
*/
public function testGetMockWithFixedClassNameCanProduceTheSameMockTwice()
{
$mock = $this->getMockBuilder('StdClass')->setMockClassName('FixedName')->getMock();
$mock = $this->getMockBuilder('StdClass')->setMockClassName('FixedName')->getMock();
$this->assertInstanceOf('StdClass', $mock);
}
public function testOriginalConstructorSettingConsidered()
{
$mock1 = $this->getMock('PartialMockTestClass');
$mock2 = $this->getMock('PartialMockTestClass', array(), array(), '', FALSE);
$this->assertTrue($mock1->constructorCalled);
$this->assertFalse($mock2->constructorCalled);
}
public function testOriginalCloneSettingConsidered()
{
$mock1 = $this->getMock('PartialMockTestClass');
$mock2 = $this->getMock('PartialMockTestClass', array(), array(), '', TRUE, FALSE);
$this->assertNotEquals(get_class($mock1), get_class($mock2));
}
public function testStubbedReturnValueForStaticMethod()
{
$this->getMockClass(
'StaticMockTestClass',
array('doSomething'),
array(),
'StaticMockTestClassMock'
);
StaticMockTestClassMock::staticExpects($this->any())
->method('doSomething')
->will($this->returnValue('something'));
$this->assertEquals(
'something', StaticMockTestClassMock::doSomething()
);
}
public function testStubbedReturnValueForStaticMethod2()
{
$this->getMockClass(
'StaticMockTestClass',
array('doSomething'),
array(),
'StaticMockTestClassMock2'
);
StaticMockTestClassMock2::staticExpects($this->any())
->method('doSomething')
->will($this->returnValue('something'));
$this->assertEquals(
'something', StaticMockTestClassMock2::doSomethingElse()
);
}
public function testGetMockForAbstractClass()
{
$mock = $this->getMock('AbstractMockTestClass');
$mock->expects($this->never())
->method('doSomething');
}
public function testStaticMethodCallWithArgumentCloningEnabled()
{
$expectedObject = new StdClass;
$this->getMockClass(
'StaticMockTestClass',
array('doSomething'),
array(),
'StaticMockTestClassMock3',
FALSE,
TRUE,
TRUE,
TRUE
);
$actualArguments = array();
StaticMockTestClassMock3::staticExpects($this->any())
->method('doSomething')
->will($this->returnCallback(function() use (&$actualArguments) {
$actualArguments = func_get_args();
}));
StaticMockTestClassMock3::doSomething($expectedObject);
$this->assertEquals(1, count($actualArguments));
$this->assertNotSame($expectedObject, $actualArguments[0]);
}
public function testStaticMethodCallWithArgumentCloningDisabled()
{
$expectedObject = new StdClass;
$this->getMockClass(
'StaticMockTestClass',
array('doSomething'),
array(),
'StaticMockTestClassMock4',
FALSE,
TRUE,
TRUE,
FALSE
);
$actualArguments = array();
StaticMockTestClassMock4::staticExpects($this->any())
->method('doSomething')
->will($this->returnCallback(function() use (&$actualArguments) {
$actualArguments = func_get_args();
}));
StaticMockTestClassMock4::doSomething($expectedObject);
$this->assertEquals(1, count($actualArguments));
$this->assertEquals($expectedObject, $actualArguments[0]);
$this->assertSame($expectedObject, $actualArguments[0]);
}
public function testObjectMethodCallWithArgumentCloningEnabled()
{
$expectedObject = new StdClass;
$mock = $this->getMockBuilder('SomeClass')
->setMethods(array('doSomethingElse'))
->enableArgumentCloning()
->getMock();
$actualArguments = array();
$mock->expects($this->any())
->method('doSomethingElse')
->will($this->returnCallback(function() use (&$actualArguments) {
$actualArguments = func_get_args();
}));
$mock->doSomethingElse($expectedObject);
$this->assertEquals(1, count($actualArguments));
$this->assertEquals($expectedObject, $actualArguments[0]);
$this->assertNotSame($expectedObject, $actualArguments[0]);
}
public function testObjectMethodCallWithArgumentCloningDisabled()
{
$expectedObject = new StdClass;
$mock = $this->getMockBuilder('SomeClass')
->setMethods(array('doSomethingElse'))
->disableArgumentCloning()
->getMock();
$actualArguments = array();
$mock->expects($this->any())
->method('doSomethingElse')
->will($this->returnCallback(function() use (&$actualArguments) {
$actualArguments = func_get_args();
}));
$mock->doSomethingElse($expectedObject);
$this->assertEquals(1, count($actualArguments));
$this->assertNotSame($expectedObject, $actualArguments[0]);
}
public function testVerificationOfMethodNameFailsWithoutParameters()
{
$mock = $this->getMock('SomeClass', array('right', 'wrong'), array(), '', TRUE, TRUE, TRUE);
$mock->expects($this->once())
->method('right');
$mock->wrong();
try {
$mock->__phpunit_verify();
$this->fail('Expected exception');
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
$this->assertSame(
"Expectation failed for method name is equal to <string:right> when invoked 1 time(s).\n"
. 'Method was expected to be called 1 times, actually called 0 times.',
$e->getMessage()
);
}
$this->resetMockObjects();
}
public function testVerificationOfMethodNameFailsWithParameters()
{
$mock = $this->getMock('SomeClass', array('right', 'wrong'), array(), '', TRUE, TRUE, TRUE);
$mock->expects($this->once())
->method('right');
$mock->wrong();
try {
$mock->__phpunit_verify();
$this->fail('Expected exception');
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
$this->assertSame(
"Expectation failed for method name is equal to <string:right> when invoked 1 time(s).\n"
. 'Method was expected to be called 1 times, actually called 0 times.',
$e->getMessage()
);
}
$this->resetMockObjects();
}
public function testVerificationOfNeverFailsWithEmptyParameters()
{
$mock = $this->getMock('SomeClass', array('right', 'wrong'), array(), '', TRUE, TRUE, TRUE);
$mock->expects($this->never())
->method('right')
->with();
try {
$mock->right();
$this->fail('Expected exception');
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
$this->assertSame(
'SomeClass::right() was not expected to be called.',
$e->getMessage()
);
}
$this->resetMockObjects();
}
public function testVerificationOfNeverFailsWithAnyParameters()
{
$mock = $this->getMock('SomeClass', array('right', 'wrong'), array(), '', TRUE, TRUE, TRUE);
$mock->expects($this->never())
->method('right')
->withAnyParameters();
try {
$mock->right();
$this->fail('Expected exception');
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
$this->assertSame(
'SomeClass::right() was not expected to be called.',
$e->getMessage()
);
}
$this->resetMockObjects();
}
/**
* @requires extension soap
*/
public function testCreateMockFromWsdl()
{
$mock = $this->getMockFromWsdl(__DIR__ . '/_files/GoogleSearch.wsdl', 'WsdlMock');
$this->assertStringStartsWith(
'Mock_WsdlMock_',
get_class($mock)
);
}
/**
* @requires extension soap
*/
public function testCreateNamespacedMockFromWsdl()
{
$mock = $this->getMockFromWsdl(__DIR__ . '/_files/GoogleSearch.wsdl', 'My\\Space\\WsdlMock');
$this->assertStringStartsWith(
'Mock_WsdlMock_',
get_class($mock)
);
}
/**
* @requires extension soap
*/
public function testCreateTwoMocksOfOneWsdlFile()
{
$mock = $this->getMockFromWsdl(__DIR__ . '/_files/GoogleSearch.wsdl');
$mock = $this->getMockFromWsdl(__DIR__ . '/_files/GoogleSearch.wsdl');
}
private function resetMockObjects()
{
$refl = new ReflectionObject($this);
$refl = $refl->getParentClass();
$prop = $refl->getProperty('mockObjects');
$prop->setAccessible(true);
$prop->setValue($this, array());
}
}

View File

@@ -0,0 +1,5 @@
<?php
abstract class AbstractMockTestClass
{
abstract public function doSomething();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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