/**
  * @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);
 }
示例#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);
 }
 /**
  * @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);
 }
示例#4
0
 /**
  * @test
  * @group entity
  */
 public function deserializing_a_serialized_entity_results_in_an_equal_value_object()
 {
     $original = new Entity(new EntityId('OpenConext.org'), EntityType::IdP());
     $deserialized = Entity::deserialize($original->serialize());
     $this->assertTrue($deserialized->equals($original));
 }