SlugifyExtensionTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. /**
  14. * SlugifyExtensionTest
  15. *
  16. * @category test
  17. * @package cocur/slugify
  18. * @subpackage bridge
  19. * @author Florian Eckerstorfer <florian@eckerstorfer.co>
  20. * @copyright 2012-2014 Florian Eckerstorfer
  21. * @license http://www.opensource.org/licenses/MIT The MIT License
  22. * @group unit
  23. */
  24. class SlugifyExtensionTest extends \PHPUnit_Framework_TestCase
  25. {
  26. /**
  27. * @var \Cocur\Slugify\SlugifyInterface|\Mockery\MockInterface
  28. */
  29. protected $slugify;
  30. /**
  31. * @var SlugifyExtension
  32. */
  33. protected $extension;
  34. protected function setUp()
  35. {
  36. $this->slugify = m::mock('Cocur\Slugify\SlugifyInterface');
  37. $this->extension = new SlugifyExtension($this->slugify);
  38. }
  39. /**
  40. * @test
  41. * @covers Cocur\Slugify\Bridge\Twig\SlugifyExtension::getFilters()
  42. */
  43. public function getFilters()
  44. {
  45. $filters = $this->extension->getFilters();
  46. $this->assertCount(1, $filters);
  47. $this->assertInstanceOf('\Twig_SimpleFilter', $filters[0]);
  48. }
  49. /**
  50. * @test
  51. * @covers Cocur\Slugify\Bridge\Twig\SlugifyExtension::slugifyFilter()
  52. */
  53. public function slugifyFilter()
  54. {
  55. $this->slugify->shouldReceive('slugify')->with('hällo wörld', '_')->once()->andReturn('haello_woerld');
  56. $this->assertEquals('haello_woerld', $this->extension->slugifyFilter('hällo wörld', '_'));
  57. }
  58. }