/** * @test * @group Entity * @group Value */ public function the_same_entity_types_are_considered_equal() { $base = EntityType::SP(); $theSame = EntityType::SP(); $different = EntityType::IdP(); $this->assertTrue($base->equals($theSame)); $this->assertFalse($base->equals($different)); }
/** * @param array $descriptor * @return Entity */ public static function fromDescriptor(array $descriptor) { Assert::count($descriptor, 2); switch ($descriptor[1]) { case 'sp': return new Entity(new EntityId($descriptor[0]), EntityType::SP()); case 'idp': return new Entity(new EntityId($descriptor[0]), EntityType::IdP()); default: throw new LogicException('Entity descriptor type neither "sp" nor "idp"'); } }
/** * @test * @group Entity * @group Value */ public function two_entities_with_the_same_entity_id_and_entity_type_are_equal() { $entityIdOne = new EntityId('one'); $entityIdTwo = new EntityId('two'); $sp = EntityType::SP(); $idp = EntityType::IdP(); $base = new Entity($entityIdOne, $sp); $theSame = new Entity($entityIdOne, $sp); $differentType = new Entity($entityIdOne, $idp); $differentId = new Entity($entityIdTwo, $sp); $differentIdAndType = new Entity($entityIdTwo, $idp); $this->assertTrue($base->equals($theSame)); $this->assertFalse($base->equals($differentType)); $this->assertFalse($base->equals($differentId)); $this->assertFalse($base->equals($differentIdAndType)); }