/** * @param array $data * @return $this */ public function import(array $data) { $this->id = $data['id']; $this->name = $data['name']; $this->countryCode = $data['country_code']; $this->countryName = $data['country_name'] ?: ''; if (is_array($data['codes'])) { foreach ($data['codes'] as $code) { $codeObj = new Code(); $this->codes[] = $codeObj->import($code); } } return $this; }
public function testCarrierCodeServiceImport() { foreach ($this->getData('carrier', 'carriers') as $data) { if (is_array($data['codes'])) { foreach ($data['codes'] as $code) { $obj = new Carrier\Code(); $obj->import($code); $this->assertEquals($code['id'], $obj->getId()); $this->assertEquals($code['carrier_id'], $obj->getCarrierId()); $this->assertEquals($code['code'], $obj->getCode()); $this->assertEquals($code['notes'], $obj->getNotes()); $this->assertInternalType('int', $obj->getId()); $this->assertInternalType('int', $obj->getCarrierId()); $this->assertInternalType('string', $obj->getCode()); $this->assertInternalType('string', $obj->getNotes()); } } } }