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'); }); }
public function testNamespaceGuess() { test::ns('demo'); $this->assertFalse(test::spec('\\UserModel')->isDefined()); $this->assertTrue(test::spec('UserModel')->isDefined()); }
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(); }