本文整理汇总了PHP中Mock::setMockBaseClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Mock::setMockBaseClass方法的具体用法?PHP Mock::setMockBaseClass怎么用?PHP Mock::setMockBaseClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mock
的用法示例。
在下文中一共展示了Mock::setMockBaseClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createClassCode
/**
* The new mock class code in string form.
* @param $class Class to replicate.
* @param $mock_class New class name.
* @static
* @access private
*/
function _createClassCode($class, $mock_class)
{
$mock_base = Mock::setMockBaseClass();
$code = "class {$mock_class} extends {$mock_base} {\n";
$code .= " function {$mock_class}(&\$test, \$wildcard = MOCK_WILDCARD) {\n";
$code .= " \$this->{$mock_base}(\$test, \$wildcard);\n";
$code .= " \$args = func_get_args();\n";
$code .= " \$this->_mockMethod(\"{$class}\", \$args);\n";
$code .= " }\n";
foreach (get_class_methods($class) as $method) {
$code .= " function {$method}() {\n";
$code .= " \$args = func_get_args();\n";
$code .= " return \$this->_mockMethod(\"{$method}\", \$args);\n";
$code .= " }\n";
}
$code .= "}\n";
return $code;
}
示例2: aMethod
function aMethod()
{
}
}
Mock::generate("Dummy");
Mock::generate("Dummy", "AnotherMockDummy");
class SpecialSimpleMock extends SimpleMock
{
function SpecialSimpleMock(&$test, $wildcard)
{
$this->SimpleMock($test, $wildcard);
}
}
Mock::setMockBaseClass("SpecialSimpleMock");
Mock::generate("Dummy", "SpecialMockDummy");
Mock::setMockBaseClass("SimpleMock");
class TestOfCodeGeneration extends UnitTestCase
{
function TestOfCodeGeneration()
{
$this->UnitTestCase();
}
function testCloning()
{
$mock =& new MockDummy($this);
$this->assertTrue(method_exists($mock, "aMethod"));
$this->assertNull($mock->aMethod());
}
function testCloningWithChosenClassName()
{
$mock =& new AnotherMockDummy($this);