Exemple #1
0
 /**
  * @param array $data
  * @return $this
  */
 public function import(array $data)
 {
     $this->id = $data['id'];
     $this->name = $data['name'];
     if ($data['codes']) {
         foreach ($data['codes'] as $code) {
             $codeObj = new Code();
             $this->codes[] = $codeObj->import($code);
         }
     }
     return $this;
 }
Exemple #2
0
 public function testDeviceMakeCodeServiceImport()
 {
     foreach ($this->getData('device-make', 'device-makes') as $data) {
         if (is_array($data['codes'])) {
             foreach ($data['codes'] as $code) {
                 $obj = new DeviceMake\Code();
                 $obj->import($code);
                 $this->assertEquals($code['code'], $obj->getCode());
                 $this->assertEquals($code['device_make_id'], $obj->getDeviceMakeId());
                 $this->assertEquals($code['id'], $obj->getId());
                 $this->assertEquals($code['notes'], $obj->getNotes());
                 $this->assertInternalType('string', $obj->getCode());
                 $this->assertInternalType('int', $obj->getDeviceMakeId());
                 $this->assertInternalType('int', $obj->getId());
                 $this->assertInternalType('string', $obj->getNotes());
             }
         }
     }
 }