SlugifyViewHelperTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Cocur\Slugify\Tests\Bridge\ZF2;
  3. use Cocur\Slugify\Bridge\ZF2\SlugifyViewHelper;
  4. use Cocur\Slugify\Slugify;
  5. /**
  6. * Class SlugifyViewHelperTest
  7. * @package cocur/slugify
  8. * @subpackage bridge
  9. * @license http://www.opensource.org/licenses/MIT The MIT License
  10. */
  11. class SlugifyViewHelperTest extends \PHPUnit_Framework_TestCase
  12. {
  13. /**
  14. * @var SlugifyViewHelper
  15. */
  16. private $viewHelper;
  17. /**
  18. * @var Slugify
  19. */
  20. private $slugify;
  21. /**
  22. * @covers Cocur\Slugify\Bridge\ZF2\SlugifyViewHelper::__construct()
  23. */
  24. protected function setUp()
  25. {
  26. $this->slugify = new Slugify();
  27. $this->viewHelper = new SlugifyViewHelper($this->slugify);
  28. }
  29. /**
  30. * @test
  31. * @covers Cocur\Slugify\Bridge\ZF2\SlugifyViewHelper::__invoke()
  32. */
  33. public function invoke()
  34. {
  35. $actual = 'Hällo Wörld';
  36. $expected = call_user_func($this->viewHelper, $actual);
  37. $this->assertEquals($expected, $this->slugify->slugify($actual));
  38. $expected = call_user_func($this->viewHelper, $actual, '_');
  39. $this->assertEquals($expected, $this->slugify->slugify($actual, '_'));
  40. }
  41. }