JMSSecurityExtraExtensionTest.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace JMS\SecurityExtraBundle\Tests\DependencyInjection;
  3. use Symfony\Component\DependencyInjection\ContainerBuilder;
  4. use JMS\SecurityExtraBundle\DependencyInjection\JMSSecurityExtraExtension;
  5. class JMSSecurityExtraExtensionTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function testConfigLoad()
  8. {
  9. $extension = new JMSSecurityExtraExtension();
  10. $config = array();
  11. $extension->load(array($config), $container = new ContainerBuilder());
  12. $this->assertTrue($container->hasDefinition('security.access.method_interceptor'));
  13. $this->assertTrue($container->hasDefinition('security.extra.controller_listener'));
  14. $this->assertFalse($container->getParameter('security.extra.secure_all_services'));
  15. $this->assertFalse($container->getDefinition('security.extra.iddqd_voter')->hasTag('security.voter'));
  16. }
  17. public function testConfigLoadSecureAll()
  18. {
  19. $extension = new JMSSecurityExtraExtension();
  20. $extension->load(array(array('secure_all_services' => true, 'secure_controllers' => false)), $container = new ContainerBuilder());
  21. $this->assertFalse($container->hasDefinition('security.extra.controller_listener'));
  22. $this->assertTrue($container->getParameter('security.extra.secure_all_services'));
  23. }
  24. public function testConfigLoadEnableIddqdAttribute()
  25. {
  26. $extension = new JMSSecurityExtraExtension();
  27. $extension->load(array(array('enable_iddqd_attribute' => true)), $container = new ContainerBuilder());
  28. $this->assertTrue($container->getDefinition('security.extra.iddqd_voter')->hasTag('security.voter'));
  29. }
  30. }