public function testUtilities() { $data = []; $data['domainId'] = 123; $data['domain'] = 'test'; $data['primaryDomain'] = new Domain(); $objOne = new Domain(); $objOne->populate($data); $this->assertEquals($data['domainId'], $objOne->getDomainId()); $this->assertEquals($data['domain'], $objOne->getDomainName()); $this->assertEquals($data['primaryDomain'], $objOne->getPrimary()); $objTwo = new Domain(); $objTwo->populateFromObject($objOne); $this->assertEquals($objOne->getDomainId(), $objTwo->getDomainId()); $this->assertEquals($objOne->getDomainName(), $objTwo->getDomainName()); $this->assertEquals($objOne->getPrimary(), $objTwo->getPrimary()); $json = json_encode($objTwo); $this->assertJson($json); $iterator = $objTwo->getIterator(); $this->assertInstanceOf('\\ArrayIterator', $iterator); $array = $objTwo->toArray(); $this->assertEquals($data['domainId'], $array['domainId']); $this->assertEquals($data['domain'], $array['domain']); $this->assertEquals($data['primaryDomain'], $array['primaryDomain']); }
/** * populate @todo some properties are missing * * @param array $data * @param array $ignore * * @return void */ public function populate(array $data, array $ignore = []) { if (!empty($data['siteId']) && !in_array('siteId', $ignore)) { $this->setSiteId($data['siteId']); } if (!empty($data['domain']) && $data['domain'] instanceof Domain && !in_array('domain', $ignore)) { $this->setDomain($data['domain']); } if (!empty($data['domain']) && is_array($data['domain']) && !in_array('domain', $ignore)) { // is this right? $domain = new Domain(); $domain->populate($data['domain']); $this->setDomain($domain); } if (!empty($data['theme']) && !in_array('theme', $ignore)) { $this->setTheme($data['theme']); } if (!empty($data['siteLayout']) && !in_array('siteLayout', $ignore)) { $this->setSiteLayout($data['siteLayout']); } if (!empty($data['siteTitle']) && !in_array('siteTitle', $ignore)) { $this->setSiteTitle($data['siteTitle']); } if (!empty($data['language']) && $data['language'] instanceof Language && !in_array('language', $ignore)) { $this->setLanguage($data['language']); } if (!empty($data['language']) && is_array($data['language']) && !in_array('language', $ignore)) { $language = new Language(); $language->populate($data['language']); $this->setLanguage($language); } if (!empty($data['country']) && $data['country'] instanceof Country && !in_array('country', $ignore)) { $this->setCountry($data['country']); } if (!empty($data['country']) && is_array($data['country']) && !in_array('country', $ignore)) { $country = new Country(); $country->populate($data['country']); $this->setCountry($country); } if (!empty($data['status']) && !in_array('status', $ignore)) { $this->setStatus($data['status']); } if (!empty($data['favIcon']) && !in_array('favIcon', $ignore)) { $this->setFavIcon($data['favIcon']); } if (!empty($data['loginPage']) && !in_array('loginPage', $ignore)) { $this->setLoginPage($data['loginPage']); } if (!empty($data['notAuthorizedPage']) && !in_array('notAuthorizedPage', $ignore)) { $this->setNotAuthorizedPage($data['notAuthorizedPage']); } if (!empty($data['notFoundPage']) && !in_array('notFoundPage', $ignore)) { $this->setNotFoundPage($data['notFoundPage']); } if (!empty($data['supportedPageTypes']) && !in_array('supportedPageTypes', $ignore)) { $this->setSupportedPageTypes($data['supportedPageTypes']); } }