|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
namespace JMS\SecurityExtraBundle\Tests\DependencyInjection\Compiler; |
|
|
4 |
|
|
|
5 |
use Symfony\Component\DependencyInjection\Definition; |
|
|
6 |
|
|
|
7 |
use JMS\SecurityExtraBundle\DependencyInjection\Compiler\SecureMethodInvocationsPass; |
|
|
8 |
|
|
|
9 |
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
|
10 |
|
|
|
11 |
class SecureMethodInvocationsTest extends \PHPUnit_Framework_TestCase |
|
|
12 |
{ |
|
|
13 |
public function testProcessThrowsNoExceptionForUndefinedClassIfSecureAll() |
|
|
14 |
{ |
|
|
15 |
$container = new ContainerBuilder(); |
|
|
16 |
$container->setDefinition('security.access.method_interceptor', new Definition()); |
|
|
17 |
$container->setParameter('security.secured_services', array()); |
|
|
18 |
|
|
|
19 |
$container->setDefinition('nonexistent.class', new Definition('FooBar')); |
|
|
20 |
|
|
|
21 |
$this->process($container); |
|
|
22 |
} |
|
|
23 |
|
|
|
24 |
/** |
|
|
25 |
* @expectedException \RuntimeException |
|
|
26 |
*/ |
|
|
27 |
public function testProcessThrowsExceptionForUndefinedClassIfNotSecureAll() |
|
|
28 |
{ |
|
|
29 |
$container = new ContainerBuilder(); |
|
|
30 |
$container->setDefinition('security.access.method_interceptor', new Definition()); |
|
|
31 |
$container->setParameter('security.secured_services', array('nonexistent.class')); |
|
|
32 |
|
|
|
33 |
$container->setDefinition('nonexistent.class', new Definition('FooBar')); |
|
|
34 |
|
|
|
35 |
$this->process($container); |
|
|
36 |
} |
|
|
37 |
|
|
|
38 |
protected function process(ContainerBuilder $container) |
|
|
39 |
{ |
|
|
40 |
$pass = new SecureMethodInvocationsPass(sys_get_temp_dir()); |
|
|
41 |
$pass->process($container); |
|
|
42 |
} |
|
|
43 |
} |