public function testValidate() { $sut = new FacebookAdSetValidator(); $adSet = new FacebookAdSet(); $adSet->setBidAmount("1234"); $result = $sut->validate($adSet); $this->assertFalse($result->getResult()); $this->assertEquals('[bidAmount] String value found, but a number or a null is required.', $result->getMessage()); }
public function fromAssociativeArray($array) { $this->adAccountId = isset($array[self::AD_ACCOUNT_ID]) ? $array[self::AD_ACCOUNT_ID] : null; $this->pageId = isset($array[self::PAGE_ID]) ? $array[self::PAGE_ID] : null; $this->accessToken = isset($array[self::ACCESS_TOKEN]) ? $array[self::ACCESS_TOKEN] : null; $this->igActorId = isset($array[self::IG_ACTOR_ID]) ? $array[self::IG_ACTOR_ID] : null; $adSets = array(); if (isset($array[self::AD_SETS])) { foreach ($array[self::AD_SETS] as $adSetArray) { $adSet = new FacebookAdSet(); $adSet->fromAssociativeArray($adSetArray); $adSets[] = $adSet; } } $this->adSets = $adSets; }
/** * @param $array array */ public function fromArray($array) { $this->status = $this->safeGet($array, self::STATUS); $this->endDate = $this->safeGet($array, self::END_DATE); $this->startDate = $this->safeGet($array, self::START_DATE); $geographicTargeting = $this->safeGet($array, self::GEOGRAPHIC_TARGETING); if (!empty($geographicTargeting)) { $this->geographicTargeting = new FacebookGeographicTargeting($geographicTargeting); } $demographicTargeting = $this->safeGet($array, self::DEMOGRAPHIC_TARGETING); if (!empty($demographicTargeting)) { $this->demographicTargeting = new FacebookDemographicTargeting($demographicTargeting); // versioned } $audienceTargeting = $this->safeGet($array, self::AUDIENCE_TARGETING); if (!empty($audienceTargeting)) { $this->audienceTargeting = new FacebookAudienceTargeting($audienceTargeting); // versioned } $this->objectsToUpdate = $this->safeGet($array, self::OBJECTS_TO_UPDATE); $this->adAccountId = $this->safeGet($array, self::AD_ACCOUNT_ID); $this->pageId = $this->safeGet($array, self::PAGE_ID); $this->accessToken = $this->safeGet($array, self::ACCESS_TOKEN); $this->igActorId = $this->safeGet($array, self::IG_ACTOR_ID); $creatives = $this->safeGet($array, self::CREATIVES, []); $this->creatives = []; foreach ($creatives as $creative) { $fbCreative = new FacebookCreative(); $fbCreative->fromArray($creative); $this->creatives[] = $fbCreative; } $adSetResults = []; $adSets = $this->safeGet($array, self::AD_SETS, []); foreach ($adSets as $adSetArray) { $adSet = new FacebookAdSet(); $adSet->fromAssociativeArray($adSetArray); $adSetResults[] = $adSet; } $this->adSets = $adSetResults; // versioned, might need builder $budget = $this->safeGet($array, self::BUDGET); if (!empty($budget)) { $budget = new Budget(null); $budget->fromArray($this->safeGet($array, self::BUDGET)); $this->budget = $budget; } }
/** * @param FacebookAdSet $adSet * @return \PaperG\FirehoundBlob\ScenarioValidators\ValidationResult */ public function validate($adSet) { return parent::validate($adSet->toAssociativeArray()); }