1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

adding method for Container

This commit is contained in:
Aidan Woods 2021-10-13 19:00:24 +01:00
parent 71d9263664
commit a9f41548d3
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
2 changed files with 8 additions and 0 deletions

View File

@ -28,6 +28,10 @@ final class Container implements TransformableRenderable
return $this->Contents;
}
public function adding(Renderable $Renderable): Container
{
return new Container(\array_merge($this->Contents, [$Renderable]));
}
/** @return string */
public function getHtml()

View File

@ -21,11 +21,15 @@ final class ContainerTest extends TestCase
new Text('bar'),
]);
$Container = $Container->adding(new Text('boo'));
$Contents = $Container->contents();
$this->assertTrue($Contents[0] instanceof Element);
$this->assertSame($Contents[0]->name(), 'foo');
$this->assertTrue($Contents[1] instanceof Text);
$this->assertSame($Contents[1]->getHtml(), 'bar');
$this->assertTrue($Contents[2] instanceof Text);
$this->assertSame($Contents[2]->getHtml(), 'boo');
}
}