mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-09-25 22:09:23 +02:00
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
28 lines
892 B
PHP
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()
|
|
);
|
|
}
|
|
}
|