本文整理汇总了PHP中AspectMock\Test::spec方法的典型用法代码示例。如果您正苦于以下问题:PHP Test::spec方法的具体用法?PHP Test::spec怎么用?PHP Test::spec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AspectMock\Test
的用法示例。
在下文中一共展示了Test::spec方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSpecUndefinedClass
public function testSpecUndefinedClass()
{
$class = test::spec('MyVirtualClass');
/** @var $class ClassProxy **/
$this->assertFalse($class->isDefined());
$this->assertFalse($class->hasMethod('__toString'));
$this->assertFalse($class->hasMethod('edit'));
verify($class->interfaces())->isEmpty();
$this->any = $class->make();
$this->any = $class->construct();
$this->specify('should return original class name', function () {
$this->assertContains('Undefined', (string) $this->any);
$this->assertContains('MyVirtualClass', (string) $this->any->__toString());
});
$this->specify('any method can be invoked', function () {
$this->assertInstanceOf('AspectMock\\Proxy\\Anything', $this->any->doSmth()->withTHis()->andThatsAll()->null());
});
$this->specify('any property can be accessed', function () {
$this->any->that = 'xxx';
$this->assertInstanceOf('AspectMock\\Proxy\\Anything', $this->any->this->that->another);
});
$this->specify('can be used as array', function () {
$this->any['has keys'];
unset($this->any['this']);
$this->any['this'] = 'that';
$this->assertFalse(isset($this->any['that']));
$this->assertInstanceOf('AspectMock\\Proxy\\Anything', $this->any['keys']);
});
$this->specify('can be iterated', function () {
foreach ($this->any as $anything) {
}
});
$this->specify('proxifies magic method calls', function () {
$any = test::doubleProxy($this->any);
$any->callMeMaybe();
$any->name = 'hello world';
$this->assertInstanceOf('AspectMock\\Proxy\\Anything', $any->name);
verify($any->class->getClassName())->equals('AspectMock\\Proxy\\Anything');
});
}
示例2: testNamespaceGuess
public function testNamespaceGuess()
{
test::ns('demo');
$this->assertFalse(test::spec('\\UserModel')->isDefined());
$this->assertTrue(test::spec('UserModel')->isDefined());
}
示例3: _before
protected function _before()
{
Test::spec('\\App\\Controller\\ErrorController');
$this->request = Test::double('\\Bone\\Mvc\\Request', array('getController' => 'index', 'getAction' => 'index'))->make();
$this->response = Test::double('\\Bone\\Mvc\\Response')->make();
}