Skip to content

Commit

Permalink
cahnge tag param to nullable in PermaLinkTag ViewHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
mamuz committed Sep 7, 2014
1 parent d6c5012 commit a0e1e56
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/MamuzBlog/View/Helper/PermaLinkTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ class PermaLinkTag extends AbstractHelper
/**
* {@link render()}
*/
public function __invoke($tagName)
public function __invoke($tagName = null)
{
return $this->render($tagName);
}

/**
* @param string $tagName
* @param string|null $tagName
* @return string
*/
public function render($tagName)
public function render($tagName = null)
{
$serverUrl = $this->getRenderer()->serverUrl();

Expand Down
23 changes: 19 additions & 4 deletions tests/MamuzBlogTest/View/Helper/PermaLinkTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ protected function setUp()
{
$this->renderer = \Mockery::mock('Zend\View\Renderer\RendererInterface');
$this->renderer->shouldReceive('serverUrl')->andReturn('server_');
$this->renderer->shouldReceive('url')->with(
'blogPublishedPosts',
array('tag' => 'tagname')
)->andReturn('url');

$this->fixture = new PermaLinkTag;
$this->fixture->setView($this->renderer);
Expand All @@ -32,6 +28,10 @@ public function testExtendingAbstractHelper()

public function testRender()
{
$this->renderer->shouldReceive('url')->with(
'blogPublishedPosts',
array('tag' => 'tagname')
)->andReturn('url');
$permaLink = $this->fixture->render('tagname');

$this->assertSame('server_url', $permaLink);
Expand All @@ -40,4 +40,19 @@ public function testRender()
$permaLink = $invoke('tagname');
$this->assertSame('server_url', $permaLink);
}

public function testRenderWithoutTagName()
{
$this->renderer->shouldReceive('url')->with(
'blogPublishedPosts',
array('tag' => null)
)->andReturn('url');
$permaLink = $this->fixture->render();

$this->assertSame('server_url', $permaLink);

$invoke = $this->fixture;
$permaLink = $invoke();
$this->assertSame('server_url', $permaLink);
}
}

0 comments on commit a0e1e56

Please sign in to comment.