/** * @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; }
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); }
public function testGetSetId() { $this->person->setId(100); $this->assertEquals(100, $this->person->getId()); }