mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-29 19:20:18 +02:00
33 lines
981 B
PHP
33 lines
981 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DesignPatterns\Structural\Composite\Tests;
|
|
|
|
use DesignPatterns\Structural\Composite\Form;
|
|
use DesignPatterns\Structural\Composite\TextElement;
|
|
use DesignPatterns\Structural\Composite\InputElement;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class CompositeTest extends TestCase
|
|
{
|
|
public function testRender()
|
|
{
|
|
$form = new Form();
|
|
$form->addElement(new TextElement('Email:'));
|
|
$form->addElement(new InputElement());
|
|
$embed = new Form();
|
|
$embed->addElement(new TextElement('Password:'));
|
|
$embed->addElement(new 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->assertSame(
|
|
'<form>Email:<input type="text" /><form>Password:<input type="text" /></form></form>',
|
|
$form->render()
|
|
);
|
|
}
|
|
}
|