public function testToFromArray() { $mockCityAction = "city action"; $this->sut->setCityAction($mockCityAction); $array = $this->sut->toArray(); $new = new FacebookGeographicTargeting($array); $this->assertEquals($this->sut, $new); $this->assertEquals($mockCityAction, $new->getCityAction()); }
public function testValidateUpdateBadBudget() { $mockAdAccountId = 'mock ad account id'; $mockPageId = 'mock page id'; $mockAccessToken = 'mock access token'; $geo = new FacebookGeographicTargeting(); $geo->setCityAction('include'); $geo->setCityIds([12, 32]); $blob = new UnmanagedFacebookBlob(); $blob->setGeographicTargeting($geo); $blob->setAdAccountId($mockAdAccountId); $blob->setPageId($mockPageId); $blob->setAccessToken($mockAccessToken); $blob->setStatus("active"); $budget = new Budget(1, "invalid"); $blob->setBudget($budget); $result = $this->sut->validateUpdate($blob); $this->assertFalse($result->getResult()); $expected = "[budget.type] Does not have a value in the enumeration [\"impression\",\"dollar\"]. " . "[budget.budget_type] Does not have a value in the enumeration [\"daily\"]. " . "[budget.type] Does not have a value in the enumeration [\"dollar\"]. " . "[budget] Failed to match all schemas. [budget] Object value found, but a null is required. " . "[budget] Failed to match exactly one schema. [] Failed to match all schemas."; $this->assertEquals($expected, $result->getMessage()); }
/** * @return array */ public function toArray() { $array = [self::STATUS => $this->status, self::START_DATE => $this->startDate, self::END_DATE => $this->endDate, self::GEOGRAPHIC_TARGETING => isset($this->geographicTargeting) ? $this->geographicTargeting->toArray() : null, self::DEMOGRAPHIC_TARGETING => isset($this->demographicTargeting) ? $this->demographicTargeting->toArray() : null, self::AUDIENCE_TARGETING => isset($this->audienceTargeting) ? $this->audienceTargeting->toArray() : null, self::OBJECTS_TO_UPDATE => $this->objectsToUpdate, self::AD_ACCOUNT_ID => $this->adAccountId, self::PAGE_ID => $this->pageId, self::ACCESS_TOKEN => $this->accessToken, self::BUDGET => isset($this->budget) ? $this->budget->toArray() : null, self::IG_ACTOR_ID => $this->igActorId, self::VERSION => self::CURRENT_VERSION]; $adSets = null; if (!empty($this->adSets)) { $adSets = []; foreach ($this->adSets as $adSet) { $adSets[] = $adSet->toAssociativeArray(); } } $array[self::AD_SETS] = $adSets; $creatives = null; if (!empty($this->creatives)) { foreach ($this->creatives as $creative) { $creatives[] = $creative->toArray(); } } $array[self::CREATIVES] = $creatives; return $array; }