コード例 #1
0
ファイル: PersonService.php プロジェクト: delboy1978uk/person
 /** 
  * @param array $data
  * @return Person
  */
 public function createFromArray(array $data)
 {
     $person = new Person();
     isset($data['id']) ? $person->setId($data['id']) : null;
     isset($data['firstname']) ? $person->setFirstname($data['firstname']) : null;
     isset($data['middlename']) ? $person->setMiddlename($data['middlename']) : null;
     isset($data['lastname']) ? $person->setLastname($data['lastname']) : null;
     isset($data['aka']) ? $person->setAka($data['aka']) : null;
     isset($data['dob']) ? $person->setDob($data['dob']) : null;
     isset($data['birthplace']) ? $person->setBirthplace($data['birthplace']) : null;
     isset($data['country']) ? $person->setCountry($data['country']) : null;
     return $person;
 }
コード例 #2
0
 public function testUpdate()
 {
     $collection = new People();
     $person = new Person();
     $person->setId(1);
     $collection->append($person);
     $person = new Person();
     $person->setId(2);
     $collection->append($person);
     $person = new Person();
     $person->setId(3);
     $collection->append($person);
     $collection->first();
     $collection->next();
     $person = $collection->current();
     //id 2
     $person->setFirstname('Theodoric');
     $collection->update($person);
     $this->assertEquals('Theodoric', $collection[1]->getFirstname());
     $person = new Person();
     $person->setId(4);
     $this->setExpectedException('LogicException');
     $collection->update($person);
 }
コード例 #3
0
ファイル: PersonTest.php プロジェクト: delboy1978uk/person
 public function testGetSetId()
 {
     $this->person->setId(100);
     $this->assertEquals(100, $this->person->getId());
 }