diff --git a/src/Helper/Placeholder.php b/src/Helper/Placeholder.php index 44619e538..d6839e50a 100644 --- a/src/Helper/Placeholder.php +++ b/src/Helper/Placeholder.php @@ -42,9 +42,7 @@ class Placeholder extends AbstractHelper public function __invoke($name = null) { if ($name === null) { - throw new InvalidArgumentException( - 'Placeholder: missing argument. $name is required by placeholder($name)' - ); + return $this; } $name = (string) $name; diff --git a/test/Helper/PlaceholderTest.php b/test/Helper/PlaceholderTest.php index 4cf507956..26734045b 100644 --- a/test/Helper/PlaceholderTest.php +++ b/test/Helper/PlaceholderTest.php @@ -58,6 +58,17 @@ public function testSetView() $this->assertSame($view, $this->placeholder->getView()); } + /** + * @return void + */ + public function testContainerExists() + { + $this->placeholder->__invoke('foo'); + $containerExists = $this->placeholder->__invoke()->containerExists('foo'); + + $this->assertTrue($containerExists); + } + /** * @return void */ @@ -67,6 +78,15 @@ public function testPlaceholderRetrievesContainer() $this->assertInstanceOf(AbstractContainer::class, $container); } + /** + * @return void + */ + public function testPlaceholderRetrievesItself() + { + $container = $this->placeholder->__invoke(); + $this->assertSame($container, $this->placeholder); + } + /** * @return void */ @@ -101,4 +121,15 @@ public function testClearContainersRemovesAllContainers() $this->assertFalse($this->placeholder->containerExists('foo')); $this->assertFalse($this->placeholder->containerExists('bar')); } + + /** + * @return void + */ + public function testGetContainerRetrievesTheCorrectContainer() + { + $container1 = $this->placeholder->__invoke('foo'); + $container2 = $this->placeholder->__invoke()->getContainer('foo'); + + $this->assertSame($container1, $container2); + } }