/** * @param array $data * @return $this */ public function import(array $data) { $this->id = $data['id']; $this->name = $data['name']; $this->sensitive = $data['is_sensitive']; $this->requiresWhitelist = $data['requires_whitelist']; $this->requiresWhitelistOnManaged = $data['requires_whitelist_on_managed']; $this->requiresWhitelistOnExternal = $data['requires_whitelist_on_external']; $this->lastModified = \DateTime::createFromFormat("Y-m-d H:i:s", $data['last_modified']); $this->brandEligible = $data['is_brand_eligible']; if (isset($data['whitelist']['countries'])) { foreach ($data['whitelist']['countries'] as $country) { $countryObj = new Country(); $this->countries[] = $countryObj->import($country); } } if (isset($data['whitelist']['countries_and_brands'])) { foreach ($data['whitelist']['countries_and_brands'] as $countryBrand) { $countryBrandObj = new CountryBrand(); $this->countriesBrands[] = $countryBrandObj->import($countryBrand); } } if (isset($data['whitelist']['regions_and_brands'])) { foreach ($data['whitelist']['regions_and_brands'] as $regionBrand) { $regionBrandObj = new RegionBrand(); $this->regionsBrands[] = $regionBrandObj->import($regionBrand); } } return $this; }
public function testCategoryCountryServiceImport() { foreach ($this->getData('category', 'categories') as $data) { if (is_array($data['whitelist']['countries'])) { foreach ($data['whitelist']['countries'] as $countries) { $obj = new Category\Country(); $obj->import($countries); $this->assertEquals($countries['country'], $obj->getCountry()); $this->assertInternalType('string', $obj->getCountry()); } } } }