more test to show the key features of patterns

This commit is contained in:
Trismegiste
2013-05-11 10:49:44 +02:00
parent 661d7e80a3
commit 44e03cae46
2 changed files with 25 additions and 3 deletions

View File

@@ -27,9 +27,13 @@ class FormTest extends \PHPUnit_Framework_TestCase
$this->assertRegExp('#^\s{4}#m', $form->render());
}
/**
* The all point of this pattern, a Composite must inherit from the node
* if you wanto to builld trees
*/
public function testFormImplementsFormEelement()
{
$this->markTestIncomplete();
$this->assertTrue(is_subclass_of('DesignPatterns\Composite\Form', 'DesignPatterns\Composite\FormElement'));
}
}

View File

@@ -37,9 +37,27 @@ class DecoratorTest extends \PHPUnit_Framework_TestCase
$this->assertXmlStringEqualsXmlString('<?xml version="1.0"?><foo>bar</foo>', $service->renderData());
}
public function testDecoratorImplementsRenderer()
/**
* The first key-point of this pattern :
*/
public function testDecoratorMustImplementsRenderer()
{
$this->markTestIncomplete();
$this->assertTrue(is_subclass_of('DesignPatterns\Decorator\Decorator', 'DesignPatterns\Decorator\Renderer'));
}
/**
* @expectedException \PHPUnit_Framework_Error
*/
public function testDecoratorTypeHinted()
{
$this->getMockForAbstractClass('DesignPatterns\Decorator\Decorator', array(new \stdClass()));
}
public function testDecoratorOnlyAcceptRenderer()
{
$mock = $this->getMock('DesignPatterns\Decorator\Renderer');
$dec = $this->getMockForAbstractClass('DesignPatterns\Decorator\Decorator', array($mock));
$this->assertNotNull($dec);
}
}