diff -r 000000000000 -r 7f95f8617b0b vendor/bundles/JMS/SecurityExtraBundle/Tests/Mapping/Driver/AnnotationDriverTest.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/bundles/JMS/SecurityExtraBundle/Tests/Mapping/Driver/AnnotationDriverTest.php Sat Sep 24 15:40:41 2011 +0200 @@ -0,0 +1,50 @@ +loadMetadataForClass(new \ReflectionClass('JMS\SecurityExtraBundle\Tests\Mapping\Driver\FooService')); + $this->assertTrue(isset($metadata->methodMetadata['foo'])); + $method = $metadata->methodMetadata['foo']; + $this->assertEquals(array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_SUPERADMIN'), $method->roles); + $this->assertEquals(array(), $method->returnPermissions); + $this->assertEquals(array(0 => array('VIEW')), $method->paramPermissions); + + $metadata = $driver->loadMetadataForClass(new \ReflectionClass('JMS\SecurityExtraBundle\Tests\Mapping\Driver\FooInterface')); + $this->assertTrue(isset($metadata->methodMetadata['foo'])); + $method = $metadata->methodMetadata['foo']; + $this->assertEquals(array(), $method->roles); + $this->assertEquals(array(0 => array('OWNER'), 1 => array('EDIT')), $method->paramPermissions); + $this->assertEquals(array('MASTER'), $method->returnPermissions); + } + + public function testLoadMetadataFromClassWithShortNotation() + { + $driver = new AnnotationDriver(new AnnotationReader()); + + $metadata = $driver->loadMetadataForClass(new \ReflectionClass('JMS\SecurityExtraBundle\Tests\Mapping\Driver\FooService')); + $this->assertTrue(isset($metadata->methodMetadata['shortNotation'])); + $method = $metadata->methodMetadata['shortNotation']; + $this->assertEquals(array('ROLE_FOO', 'ROLE_BAR'), $method->roles); + } + + public function testLoadMetadataFromClassDoesNotProcessMethodsForWhichNoSecurityMetadataExists() + { + $driver = new AnnotationDriver(new AnnotationReader()); + + $metadata = $driver->loadMetadataForClass(new \ReflectionClass('JMS\SecurityExtraBundle\Tests\Fixtures\MainService')); + $this->assertTrue(class_exists('JMS\SecurityExtraBundle\Tests\Fixtures\Annotation\NonSecurityAnnotation', false)); + $this->assertFalse(isset($metadata->methodMetadata['foo'])); + } +} \ No newline at end of file