Ejemplo n.º 1
0
 public function testFindOneByCriteria()
 {
     $person = $this->svc->createFromArray(['firstname' => 'Derek', 'middlename' => 'Stephen', 'lastname' => 'McLean', 'aka' => 'Delboy', 'dob' => new DateTime('1978-02-17'), 'birthplace' => 'Glasgow', 'country' => CountryFactory::generate('GBR')]);
     $this->svc->savePerson($person);
     $person = $this->svc->createFromArray(['firstname' => 'Another', 'middlename' => 'Person', 'lastname' => 'Added', 'aka' => 'Nobody', 'dob' => new DateTime('1979-03-18'), 'birthplace' => 'Manchester', 'country' => CountryFactory::generate('GBR')]);
     $this->svc->savePerson($person);
     $person = $this->svc->createFromArray(['firstname' => 'Yet', 'middlename' => 'Another', 'lastname' => 'Person', 'aka' => 'Someone', 'dob' => new DateTime('1980-04-19'), 'birthplace' => 'Kingston', 'country' => CountryFactory::generate('JAM')]);
     $person = $this->svc->savePerson($person);
     $criteria = new PersonCriteria();
     $criteria->setId($person->getId());
     $person = $this->svc->findOneByCriteria($criteria);
     $this->assertInstanceOf('Del\\Person\\Entity\\Person', $person);
     $criteria = new PersonCriteria();
     $criteria->setFirstname('Derek');
     $person = $this->svc->findOneByCriteria($criteria);
     $this->assertInstanceOf('Del\\Person\\Entity\\Person', $person);
     $criteria = new PersonCriteria();
     $criteria->setMiddlename('Person');
     $person = $this->svc->findOneByCriteria($criteria);
     $this->assertInstanceOf('Del\\Person\\Entity\\Person', $person);
     $criteria = new PersonCriteria();
     $criteria->setLastname('McLean');
     $person = $this->svc->findOneByCriteria($criteria);
     $this->assertInstanceOf('Del\\Person\\Entity\\Person', $person);
     $criteria = new PersonCriteria();
     $criteria->setAka('Someone');
     $person = $this->svc->findOneByCriteria($criteria);
     $this->assertInstanceOf('Del\\Person\\Entity\\Person', $person);
     $criteria = new PersonCriteria();
     $criteria->setBirthplace('Glasgow');
     $person = $this->svc->findOneByCriteria($criteria);
     $this->assertInstanceOf('Del\\Person\\Entity\\Person', $person);
     $this->svc->deletePerson($person);
     $criteria = new PersonCriteria();
     $criteria->setDob('1979-03-18');
     $person = $this->svc->findOneByCriteria($criteria);
     $this->assertInstanceOf('Del\\Person\\Entity\\Person', $person);
     $this->svc->deletePerson($person);
     $criteria = new PersonCriteria();
     $criteria->setCountry('JAM');
     $person = $this->svc->findOneByCriteria($criteria);
     $this->assertInstanceOf('Del\\Person\\Entity\\Person', $person);
     $this->svc->deletePerson($person);
 }