public function testSetGetPerson()
 {
     $donor = new Donor();
     $donor->setFirstname('Test')->setSurname('Recipient');
     $address = new Address();
     $address->setAddressLine('Test Address')->setTown('Some Town')->setPostcode('Postcode');
     $donor->addAddress($address);
     $this->correspondence->setCorrespondent($donor);
     $this->assertInstanceOf('Opg\\Core\\Model\\Entity\\CaseActor\\Donor', $this->correspondence->getCorrespondent());
     $this->assertEquals($donor, $this->correspondence->getCorrespondent());
     $this->assertEquals($address, $this->correspondence->getCorrespondent()->getAddresses()->toArray()[0]);
 }
 public function testToString()
 {
     $expected = "Test *1*2*3*Test Town*Test County*SW3 4HG*Test Country";
     $donor = new Donor();
     $donor->setId(1);
     $donor->setFirstName('Test');
     $this->address->setPerson($donor);
     $this->assertEquals($donor, $this->address->getPerson());
     $this->address->setAddressLines(array(1, 2, 3))->setTown('Test Town')->setCounty('Test County')->setPostcode('SW3 4HG')->setCountry('Test Country');
     $result = $this->address->toString('*', Address::INCLUDE_PERSON, 0b111);
     $this->assertEquals($expected, trim($result));
 }
 /**
  * @param  \Opg\Core\Model\Entity\Address\Address $address
  *
  * @return Person
  */
 public function addAddress(Address $address = null)
 {
     $address->setPerson($this);
     $this->addresses->add($address);
     return $this;
 }
 public function testAddressFunctions()
 {
     $this->person->clearAddresses();
     $this->assertEmpty($this->person->getAddresses()->toArray());
     $homeAddress = new Address();
     $homeAddress->setId(1)->setAddressLines(array('My Address', 'My Street'))->setTown('My Town')->setPostcode('My Postcode')->setType('home');
     $workAddress = new Address();
     $workAddress->setId(2)->setAddressLines(array('My Work Address', 'My Street'))->setTown('My Town')->setPostcode('My Postcode')->setType('work');
     $this->person->addAddress($homeAddress);
     $this->person->addAddress($workAddress);
     $addressCollection = $this->person->getAddresses();
     $this->assertTrue($addressCollection->contains($homeAddress));
     $this->assertTrue($addressCollection->contains($workAddress));
     $this->person->setAddresses($addressCollection);
     $this->assertEquals($addressCollection, $this->person->getAddresses());
 }