diff -r 000000000000 -r 7f95f8617b0b vendor/bundles/JMS/SecurityExtraBundle/Tests/Generator/ProxyClassGeneratorTest.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/bundles/JMS/SecurityExtraBundle/Tests/Generator/ProxyClassGeneratorTest.php Sat Sep 24 15:40:41 2011 +0200 @@ -0,0 +1,73 @@ +roles = array('ROLE_FOO'); + $methodMetadata->returnPermissions = array('PERMISSION_RETURN'); + $metadata->addMethodMetadata($methodMetadata); + + $definition = new Definition(); + $definition->setClass($class); + + list($className, $proxy) = $generator->generate($definition, $metadata); + $tmpFile = tempnam(sys_get_temp_dir(), 'proxy'); + file_put_contents($tmpFile, $proxy); + require_once $tmpFile; + unlink($tmpFile); + + $className = 'SecurityProxies\\'.$className; + $proxyClass = new $className; + + $mock = $this->getMockBuilder('JMS\SecurityExtraBundle\Security\Authorization\Interception\MethodSecurityInterceptor') + ->disableOriginalConstructor() + ->getMock(); + $mock + ->expects($this->once()) + ->method('invoke') + ->will($this->returnValue($return = new \stdClass())) + ; + $proxyClass->jmsSecurityExtraBundle__setMethodSecurityInterceptor($mock); + + $this->assertSame($return, call_user_func_array(array($proxyClass, $method), $arguments)); + } + + public function getTestData() + { + return array( + array('JMS\SecurityExtraBundle\Tests\Generator\FooService', 'foo', array('foo')), + array('JMS\SecurityExtraBundle\Tests\Generator\AnotherService', 'foo', array()), + ); + } +} + +class AnotherService +{ + public function foo() + { + } +} + +class FooService +{ + public function foo($fooParam) + { + return 'foo'; + } +} \ No newline at end of file