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']));
 }
Example #2
0
 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 testLoadMetadataFromClassWithRolesAndPermissionsArrayNotation()
 {
     $driver = new AnnotationDriver(new AnnotationReader());
     $metadata = $driver->loadMetadataForClass(new \ReflectionClass('JMS\\SecurityExtraBundle\\Tests\\Mapping\\Driver\\FooService'));
     $this->assertTrue(isset($metadata->methodMetadata['bar']));
     $method = $metadata->methodMetadata['bar'];
     $this->assertEquals(array('ROLE_FOO', 'ROLE_BAR'), $method->roles);
     $this->assertEquals(array(0 => array('OWNER')), $method->paramPermissions);
     $this->assertEquals(array('MASTER'), $method->returnPermissions);
 }
 /**
  * @param $class
  * @return \JMS\SecurityExtraBundle\Metadata\ClassMetadata
  */
 public function getMetadata($class)
 {
     return $this->metadataReader->loadMetadataForClass(new \ReflectionClass($class));
 }