Skip to content

Commit

Permalink
Fixes laminas#7 Fix Placeholder view helper return value
Browse files Browse the repository at this point in the history
Signed-off-by: Abdul Malik Ikhsan <[email protected]>
  • Loading branch information
samsonasik committed Jul 17, 2020
1 parent 7ce6f38 commit 537c3ad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/Helper/Placeholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 31 additions & 0 deletions test/Helper/PlaceholderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
*/
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 537c3ad

Please sign in to comment.