public function testToFromArray() { $mockIds = ["mock ids"]; $mockType = "mock type"; $this->sut->setIds($mockIds); $this->sut->setType($mockType); $array = $this->sut->toArray(); $test = new FacebookAudienceTargeting($array); $this->assertEquals($this->sut, $test); }
/** * @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; }