Files
DesignPatternsPHP/Structural/Composite/Tests/CompositeTest.php
Matt Campbell 4f7d797567 Composite Test: Add information about nested forms
Add information for composite pattern test to hopefully
help to not mislead anyone viewing this test, into thinking
that they can nest HTML form elements.

Closes #264
2017-02-17 20:16:41 +00:00

28 lines
892 B
PHP

<?php
namespace DesignPatterns\Structural\Composite\Tests;
use DesignPatterns\Structural\Composite;
class CompositeTest extends \PHPUnit_Framework_TestCase
{
public function testRender()
{
$form = new Composite\Form();
$form->addElement(new Composite\TextElement('Email:'));
$form->addElement(new Composite\InputElement());
$embed = new Composite\Form();
$embed->addElement(new Composite\TextElement('Password:'));
$embed->addElement(new Composite\InputElement());
$form->addElement($embed);
// This is just an example, in a real world scenario it is important to remember that web browsers do not
// currently support nested forms
$this->assertEquals(
'<form>Email:<input type="text" /><form>Password:<input type="text" /></form></form>',
$form->render()
);
}
}