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. use Mockery\Adapter\Phpunit\MockeryTestCase;
  6. /**
  7. * Class SlugifyViewHelperTest
  8. * @package cocur/slugify
  9. * @subpackage bridge
  10. * @license http://www.opensource.org/licenses/MIT The MIT License
  11. */
  12. class SlugifyViewHelperTest extends MockeryTestCase
  13. {
  14. /**
  15. * @var SlugifyViewHelper
  16. */
  17. private $viewHelper;
  18. /**
  19. * @var Slugify
  20. */
  21. private $slugify;
  22. /**
  23. * @covers \Cocur\Slugify\Bridge\ZF2\SlugifyViewHelper::__construct()
  24. */
  25. protected function setUp(): void
  26. {
  27. $this->slugify = new Slugify();
  28. $this->viewHelper = new SlugifyViewHelper($this->slugify);
  29. }
  30. /**
  31. * @covers \Cocur\Slugify\Bridge\ZF2\SlugifyViewHelper::__invoke()
  32. */
  33. public function testInvoke()
  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. }