From 44e03cae467954a8cdbc19b5f32bd3081d45e844 Mon Sep 17 00:00:00 2001 From: Trismegiste Date: Sat, 11 May 2013 10:49:44 +0200 Subject: [PATCH] more test to show the key features of patterns --- Tests/Composite/FormTest.php | 6 +++++- Tests/Decorator/DecoratorTest.php | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Tests/Composite/FormTest.php b/Tests/Composite/FormTest.php index 71a275c..a706c99 100644 --- a/Tests/Composite/FormTest.php +++ b/Tests/Composite/FormTest.php @@ -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')); } } \ No newline at end of file diff --git a/Tests/Decorator/DecoratorTest.php b/Tests/Decorator/DecoratorTest.php index 4eee22b..35e19a7 100644 --- a/Tests/Decorator/DecoratorTest.php +++ b/Tests/Decorator/DecoratorTest.php @@ -37,9 +37,27 @@ class DecoratorTest extends \PHPUnit_Framework_TestCase $this->assertXmlStringEqualsXmlString('bar', $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); } } \ No newline at end of file