public function test_isValid_WithInvalidType_ReturnsFalse() { $dummyType = 'some_link_no_one_knows'; $mockName = "mockName"; $mockCreativeData = new FacebookCreativeData(); $mockCreativeData->setName($mockName); $this->sut->setType($dummyType); $this->sut->setPrimary($mockCreativeData); $this->assertEquals(false, $this->sut->isValid()); }
public function testValidateCreate() { $adSet = new FacebookAdSet(); $creative = new FacebookCreative(); $creativeData = new FacebookCreativeData(); $creativeData->setMediaUrl("blah"); $creativeData->setName('name'); $creative->setPrimary($creativeData); $creative->setType('link'); $blob = new UnmanagedFacebookBlob(); $blob->setStatus("active"); $blob->setAdSets([$adSet]); $blob->setCreatives([$creative]); $blob->setAdAccountId('ad account id'); $blob->setPageId(1234); $blob->setAccessToken('access token'); $result = $this->sut->validateCreate($blob); $this->assertEmpty($result->getMessage()); $this->assertTrue($result->getResult()); }
public function test_isValidCreateBlob_UsingAValidBlobForCreate_WithIntPage_ReturnsTrue() { $mockScenarioBlob = $this->getMockBuilder('PaperG\\FirehoundBlob\\ScenarioBlob')->disableOriginalConstructor()->getMock(); $mockUnmanagedFbBlob = new UnmanagedFacebookBlob(); $mockAdSet = new FacebookAdSet(); $mockCreative = new FacebookCreative(); $mockCreativeData = new FacebookCreativeData(); $mockCreativeData->setMediaUrl("media url"); $mockCreativeData->setName('mock name'); $mockCreative->setType('link'); $mockCreative->setPrimary($mockCreativeData); $mockBudget = new Budget(1, 'dollar', 'daily'); $mockUnmanagedFbBlob->setAdAccountId('123-abc'); $mockUnmanagedFbBlob->setPageId('123-abc'); $mockUnmanagedFbBlob->setAccessToken('123-abc'); $mockUnmanagedFbBlob->setStatus('active'); $mockUnmanagedFbBlob->setCreatives([$mockCreative]); $mockUnmanagedFbBlob->setAdSets([$mockAdSet]); $mockUnmanagedFbBlob->setBudget($mockBudget); $mockScenarioBlob->expects($this->once())->method('getBlob')->will($this->returnValue($mockUnmanagedFbBlob)); $results = $this->sut->isValidCreateBlob($mockScenarioBlob); $this->assertEquals(true, $results->getResult()); }
/** * @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; } }