CocurSlugifyExtensionTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\Bundle;
  11. use Cocur\Slugify\Bridge\Symfony\CocurSlugifyExtension;
  12. use \Mockery as m;
  13. /**
  14. * CocurSlugifyExtensionTest
  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 CocurSlugifyExtensionTest extends \PHPUnit_Framework_TestCase
  25. {
  26. public function setUp()
  27. {
  28. $this->extension = new CocurSlugifyExtension();
  29. }
  30. /**
  31. * @test
  32. * @covers Cocur\Slugify\Bridge\Symfony\CocurSlugifyExtension::load()
  33. */
  34. public function load()
  35. {
  36. $twigDefinition = m::mock('Symfony\Component\DependencyInjection\Definition');
  37. $twigDefinition
  38. ->shouldReceive('addTag')
  39. ->with('twig.extension')
  40. ->once()
  41. ->andReturn($twigDefinition);
  42. $twigDefinition
  43. ->shouldReceive('setPublic')
  44. ->with(false)
  45. ->once();
  46. $container = m::mock('Symfony\Component\DependencyInjection\ContainerBuilder');
  47. $container
  48. ->shouldReceive('setDefinition')
  49. ->with('cocur_slugify', m::type('Symfony\Component\DependencyInjection\Definition'))
  50. ->once();
  51. $container
  52. ->shouldReceive('setDefinition')
  53. ->with('cocur_slugify.twig.slugify', m::type('Symfony\Component\DependencyInjection\Definition'))
  54. ->once()
  55. ->andReturn($twigDefinition);
  56. $container
  57. ->shouldReceive('setAlias')
  58. ->with('slugify', 'cocur_slugify')
  59. ->once();
  60. $this->extension->load(array(), $container);
  61. }
  62. }