SlugifyExtensionTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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\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. public function setUp()
  27. {
  28. $this->slugify = m::mock('Cocur\Slugify\SlugifyInterface');
  29. $this->extension = new SlugifyExtension($this->slugify);
  30. }
  31. /**
  32. * @test
  33. * @covers Cocur\Slugify\Bridge\Twig\SlugifyExtension::getName()
  34. */
  35. public function getName($withDataSet = true)
  36. {
  37. $this->assertEquals('slugify_extension', $this->extension->getName());
  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. }