Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #7 Fix Placeholder view helper return value #49

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}