Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
89 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace MamuzBlog\View\Helper; | ||
|
||
class PermaLinkTag extends AbstractHelper | ||
{ | ||
/** | ||
* {@link render()} | ||
*/ | ||
public function __invoke($tagName) | ||
{ | ||
return $this->render($tagName); | ||
} | ||
|
||
/** | ||
* @param string $tagName | ||
* @return string | ||
*/ | ||
public function render($tagName) | ||
{ | ||
$serverUrl = $this->getRenderer()->serverUrl(); | ||
|
||
$url = $this->getRenderer()->url( | ||
'blogPublishedPosts', | ||
array('tag' => $tagName) | ||
); | ||
|
||
return $serverUrl . $url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace MamuzBlogTest\View\Helper; | ||
|
||
use MamuzBlog\View\Helper\PermaLinkTag; | ||
|
||
class PermaLinkTagTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var PermaLinkTag */ | ||
protected $fixture; | ||
|
||
/** @var \Zend\View\Renderer\RendererInterface | \Mockery\MockInterface */ | ||
protected $renderer; | ||
|
||
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); | ||
} | ||
|
||
public function testExtendingAbstractHelper() | ||
{ | ||
$this->assertInstanceOf('MamuzBlog\View\Helper\AbstractHelper', $this->fixture); | ||
} | ||
|
||
public function testRender() | ||
{ | ||
$permaLink = $this->fixture->render('tagname'); | ||
|
||
$this->assertSame('server_url', $permaLink); | ||
|
||
$invoke = $this->fixture; | ||
$permaLink = $invoke('tagname'); | ||
$this->assertSame('server_url', $permaLink); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters