/** * @test * @group entity */ public function elements_in_a_set_can_be_tested_for_presence_based_on_equality() { $entityInSetOne = new Entity(new EntityId('RUG'), EntityType::SP()); $entityInSetTwo = new Entity(new EntityId('HU'), EntityType::IdP()); $entityNotInSet = new Entity(new EntityId('UM'), EntityType::IdP()); $entitySet = new EntitySet(array($entityInSetOne, $entityInSetTwo)); $this->assertTrue($entitySet->contains($entityInSetOne)); $this->assertTrue($entitySet->contains(new Entity(new EntityId('HU'), EntityType::IdP()))); $this->assertFalse($entitySet->contains($entityNotInSet)); }
/** * @param EntitySet $other * @return bool */ public function equals(EntitySet $other) { if (count($this->entities) !== count($other->entities)) { return false; } foreach ($this->entities as $entity) { if (!$other->contains($entity)) { return false; } } return true; }