SlugifyExtensionTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * This file is part of cocur/slugify.
  4. *
  5. * (c) Florian Eckerstorfer <florian@eckerstorfer.co>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Cocur\Slugify\Tests\Bridge\Twig;
  11. use Cocur\Slugify\Bridge\Twig\SlugifyExtension;
  12. use Mockery as m;
  13. use Mockery\Adapter\Phpunit\MockeryTestCase;
  14. /**
  15. * SlugifyExtensionTest
  16. *
  17. * @category test
  18. * @package cocur/slugify
  19. * @subpackage bridge
  20. * @author Florian Eckerstorfer <florian@eckerstorfer.co>
  21. * @copyright 2012-2014 Florian Eckerstorfer
  22. * @license http://www.opensource.org/licenses/MIT The MIT License
  23. * @group unit
  24. */
  25. class SlugifyExtensionTest extends MockeryTestCase
  26. {
  27. /**
  28. * @var \Cocur\Slugify\SlugifyInterface|\Mockery\MockInterface
  29. */
  30. protected $slugify;
  31. /**
  32. * @var SlugifyExtension
  33. */
  34. protected $extension;
  35. protected function setUp(): void
  36. {
  37. $this->slugify = m::mock('Cocur\Slugify\SlugifyInterface');
  38. $this->extension = new SlugifyExtension($this->slugify);
  39. }
  40. /**
  41. * @covers \Cocur\Slugify\Bridge\Twig\SlugifyExtension::getFilters()
  42. */
  43. public function testGetFilters()
  44. {
  45. $filters = $this->extension->getFilters();
  46. $this->assertCount(1, $filters);
  47. $this->assertInstanceOf('\Twig\TwigFilter', $filters[0]);
  48. }
  49. /**
  50. * @covers \Cocur\Slugify\Bridge\Twig\SlugifyExtension::slugifyFilter()
  51. */
  52. public function testSlugifyFilter()
  53. {
  54. $this->slugify->shouldReceive('slugify')->with('hällo wörld', '_')->once()->andReturn('haello_woerld');
  55. $this->assertSame('haello_woerld', $this->extension->slugifyFilter('hällo wörld', '_'));
  56. }
  57. }