mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-28 18:50:11 +02:00
29 lines
905 B
PHP
29 lines
905 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Structural\Composite\Tests;
|
|
|
|
use DesignPatterns\Structural\Composite;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class CompositeTest extends 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()
|
|
);
|
|
}
|
|
}
|