Ejemplo n.º 1
0
 /**
  * @test
  * @group entity
  */
 public function an_entity_type_can_be_cast_to_string()
 {
     $spAsString = (string) EntityType::SP();
     $idpAsString = (string) EntityType::IdP();
     $this->assertEquals(EntityType::TYPE_SP, $spAsString);
     $this->assertEquals(EntityType::TYPE_IDP, $idpAsString);
 }
Ejemplo n.º 2
0
 /**
  * @param array $descriptor array('entity-id', 'sp or idp')
  * @return Entity
  */
 public static function fromDescriptor(array $descriptor)
 {
     Assertion::count($descriptor, 2, 'EntityDescriptor must be an array with two elements (both a string), the first must be the EntityId, the ' . 'second the EntityType');
     Assertion::inArray($descriptor[1], array('sp', 'idp'), 'Entity descriptor type is neither "sp" nor "idp"');
     if ($descriptor[1] === 'sp') {
         $entityType = EntityType::SP();
     } else {
         $entityType = EntityType::IdP();
     }
     return new Entity(new EntityId($descriptor[0]), $entityType);
 }
Ejemplo n.º 3
0
 /**
  * @test
  * @group entity
  */
 public function an_entity_set_can_be_cast_to_a_known_format_string()
 {
     $entityOne = new Entity(new EntityId('RUG'), EntityType::SP());
     $entityTwo = new Entity(new EntityId('HU'), EntityType::IdP());
     $entities = array($entityOne, $entityTwo);
     $entitySet = new EntitySet($entities);
     $this->assertEquals(sprintf('EntitySet["%s"]', implode('", "', $entities)), (string) $entitySet);
 }
Ejemplo n.º 4
0
 /**
  * @test
  * @group entity
  */
 public function an_entity_can_be_cast_to_a_known_format_string()
 {
     $entityId = new EntityId('OpenConext');
     $entityType = EntityType::SP();
     $entity = new Entity($entityId, $entityType);
     $expected = sprintf('%s (%s)', $entityId, $entityType);
     $this->assertEquals($expected, (string) $entity);
 }