mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-07 07:26:32 +02:00
create a Test folder for each pattern
This commit is contained in:
36
Structural/Composite/Tests/CompositeTest.php
Normal file
36
Structural/Composite/Tests/CompositeTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Test\Composite\Tests;
|
||||
|
||||
use DesignPatterns\Structural\Composite;
|
||||
|
||||
/**
|
||||
* FormTest tests the composite pattern on Form
|
||||
*/
|
||||
class CompositeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testRender()
|
||||
{
|
||||
$form = new Composite\Form();
|
||||
$form->addElement(new Composite\TextElement());
|
||||
$form->addElement(new Composite\InputElement());
|
||||
$embed = new Composite\Form();
|
||||
$embed->addElement(new Composite\TextElement());
|
||||
$embed->addElement(new Composite\InputElement());
|
||||
$form->addElement($embed); // here we have a embedded form (like SF2 does)
|
||||
|
||||
$this->assertRegExp('#^\s{4}#m', $form->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* The all point of this pattern, a Composite must inherit from the node
|
||||
* if you want to builld trees
|
||||
*/
|
||||
public function testFormImplementsFormEelement()
|
||||
{
|
||||
$className = 'DesignPatterns\Structural\Composite\Form';
|
||||
$abstractName = 'DesignPatterns\Structural\Composite\FormElement';
|
||||
$this->assertTrue(is_subclass_of($className, $abstractName));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user