本文整理汇总了PHP中SimpleTest::setMockBaseClass方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleTest::setMockBaseClass方法的具体用法?PHP SimpleTest::setMockBaseClass怎么用?PHP SimpleTest::setMockBaseClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleTest
的用法示例。
在下文中一共展示了SimpleTest::setMockBaseClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: StubDummy
$stub =& new StubDummy();
$stub->setReturnValueAt(0, "anotherMethod", "aaa");
$stub->setReturnValue("aMethod", "AAA");
$this->assertIdentical($stub->aMethod(), "AAA");
$this->assertIdentical($stub->anotherMethod(), "aaa");
}
}
Mock::generate('Dummy');
Mock::generate('Dummy', 'AnotherMockDummy');
Mock::generate('Dummy', 'MockDummyWithExtraMethods', array('extraMethod'));
class SpecialSimpleMock extends SimpleMock
{
}
SimpleTest::setMockBaseClass("SpecialSimpleMock");
Mock::generate("Dummy", "SpecialMockDummy");
SimpleTest::setMockBaseClass("SimpleMock");
class TestOfMockGeneration extends UnitTestCase
{
function testCloning()
{
$mock =& new MockDummy();
$this->assertTrue(method_exists($mock, "aMethod"));
$this->assertNull($mock->aMethod());
}
function testCloningWithExtraMethod()
{
$mock =& new MockDummyWithExtraMethods();
$this->assertTrue(method_exists($mock, "extraMethod"));
}
function testCloningWithChosenClassName()
{
示例2: testMaximumCallsSatisfiedByNoCalls
function testMaximumCallsSatisfiedByNoCalls()
{
$mock = new MockDummy();
$mock->expectMaximumCallCount('aMethod', 1);
}
}
class MockWithInjectedTestCase extends SimpleMock
{
protected function getCurrentTestCase()
{
return SimpleTest::getContext()->getTest()->getMockedTest();
}
}
SimpleTest::setMockBaseClass('MockWithInjectedTestCase');
Mock::generate('Dummy', 'MockDummyWithInjectedTestCase');
SimpleTest::setMockBaseClass('SimpleMock');
Mock::generate('SimpleTestCase');
class LikeExpectation extends IdenticalExpectation
{
function __construct($expectation)
{
$expectation->message = '';
parent::__construct($expectation);
}
function test($compare)
{
$compare->message = '';
return parent::test($compare);
}
function testMessage($compare)
{