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:
parent
71d9263664
commit
a9f41548d3
@ -28,6 +28,10 @@ final class Container implements TransformableRenderable
|
|||||||
return $this->Contents;
|
return $this->Contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function adding(Renderable $Renderable): Container
|
||||||
|
{
|
||||||
|
return new Container(\array_merge($this->Contents, [$Renderable]));
|
||||||
|
}
|
||||||
|
|
||||||
/** @return string */
|
/** @return string */
|
||||||
public function getHtml()
|
public function getHtml()
|
||||||
|
@ -21,11 +21,15 @@ final class ContainerTest extends TestCase
|
|||||||
new Text('bar'),
|
new Text('bar'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$Container = $Container->adding(new Text('boo'));
|
||||||
|
|
||||||
$Contents = $Container->contents();
|
$Contents = $Container->contents();
|
||||||
|
|
||||||
$this->assertTrue($Contents[0] instanceof Element);
|
$this->assertTrue($Contents[0] instanceof Element);
|
||||||
$this->assertSame($Contents[0]->name(), 'foo');
|
$this->assertSame($Contents[0]->name(), 'foo');
|
||||||
$this->assertTrue($Contents[1] instanceof Text);
|
$this->assertTrue($Contents[1] instanceof Text);
|
||||||
$this->assertSame($Contents[1]->getHtml(), 'bar');
|
$this->assertSame($Contents[1]->getHtml(), 'bar');
|
||||||
|
$this->assertTrue($Contents[2] instanceof Text);
|
||||||
|
$this->assertSame($Contents[2]->getHtml(), 'boo');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user