public function setup()
 {
     parent::setup();
     $this->productCatalog = new ProductCatalog(null, $this->getBusinessManagerId());
     $this->productCatalog->setData(array(ProductCatalogFields::NAME => $this->getTestRunId()));
     $this->productCatalog->create();
 }
 public function setup()
 {
     parent::setup();
     $this->productCatalog = new ProductCatalog(null, $this->getConfig()->businessId);
     $this->productCatalog->setData(array(ProductCatalogFields::NAME => $this->getConfig()->testRunId));
     $this->productCatalog->create();
 }
Exemple #3
0
 public function setup()
 {
     parent::setup();
     $targeting = new TargetingSpecs();
     $targeting->{TargetingSpecsFields::GEO_LOCATIONS} = array('countries' => array('US'));
     $this->campaign = new Campaign(null, $this->getConfig()->accountId);
     $this->campaign->{CampaignFields::NAME} = $this->getConfig()->testRunId;
     $this->campaign->create();
     $this->adSet = new AdSet(null, $this->getConfig()->accountId);
     $this->adSet->{AdSetFields::CAMPAIGN_ID} = (int) $this->campaign->{AdSetFields::ID};
     $this->adSet->{AdSetFields::NAME} = $this->getConfig()->testRunId;
     $this->adSet->{AdSetFields::DAILY_BUDGET} = '150';
     $this->adSet->{AdSetFields::START_TIME} = (new \DateTime("+1 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdSetFields::END_TIME} = (new \DateTime("+2 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdSetFields::TARGETING} = $targeting;
     $this->adSet->{AdSetFields::OPTIMIZATION_GOAL} = OptimizationGoals::REACH;
     $this->adSet->{AdSetFields::BILLING_EVENT} = BillingEvents::IMPRESSIONS;
     $this->adSet->{AdSetFields::BID_AMOUNT} = 2;
     $this->adSet->save(array(AdSet::STATUS_PARAM_NAME => AdSet::STATUS_PAUSED));
     $this->adImage = new AdImage(null, $this->getConfig()->accountId);
     $this->adImage->{AdImageFields::FILENAME} = $this->getConfig()->testImagePath;
     $this->adImage->save();
     $link = new LinkData();
     $link->{LinkDataFields::MESSAGE} = 'Message';
     $link->{LinkDataFields::IMAGE_HASH} = $this->adImage->{AdImageFields::HASH};
     $link->{LinkDataFields::LINK} = $this->getConfig()->appUrl;
     $story = new ObjectStorySpec();
     $story->{ObjectStorySpecFields::PAGE_ID} = $this->getConfig()->pageId;
     $story->{ObjectStorySpecFields::LINK_DATA} = $link;
     $this->adCreative = new AdCreative(null, $this->getConfig()->accountId);
     $this->adCreative->{AdCreativeFields::OBJECT_STORY_SPEC} = $story;
     $this->adCreative->create();
 }
 public function setup()
 {
     parent::setup();
     $this->adCampaign = new AdCampaign(null, $this->getConfig()->accountId);
     $this->adCampaign->{AdCampaignFields::NAME} = $this->getConfig()->testRunId;
     $this->adCampaign->create();
 }
 public function setup()
 {
     parent::setup();
     $this->adLabel = new AdLabel(null, $this->getConfig()->accountId);
     $this->adLabel->{AdLabelFields::NAME} = $this->getConfig()->testRunId;
     $this->adLabel->create();
 }
 public function setup()
 {
     parent::setup();
     $this->adCampaign = new AdCampaign(null, $this->getActId());
     $this->adCampaign->{AdCampaignFields::NAME} = $this->getTestRunId();
     $this->adCampaign->create();
 }
 public function setup()
 {
     parent::setup();
     $this->adCampaign = new AdCampaign(null, $this->getActId());
     $this->adCampaign->{AdCampaignFields::NAME} = $this->getTestRunId();
     $this->adCampaign->create();
     $this->adSet = new AdSet(null, $this->getActId());
     $this->adSet->{AdSetFields::CAMPAIGN_GROUP_ID} = (int) $this->adCampaign->{AdSetFields::ID};
     $this->adSet->{AdSetFields::NAME} = $this->getTestRunId();
     $this->adSet->{AdSetFields::CAMPAIGN_STATUS} = AdSet::STATUS_PAUSED;
     $this->adSet->{AdSetFields::DAILY_BUDGET} = '150';
     $this->adSet->{AdSetFields::START_TIME} = (new \DateTime("+1 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdSetFields::END_TIME} = (new \DateTime("+2 week"))->format(\DateTime::ISO8601);
     $this->adSet->create();
     $this->adImage = new AdImage(null, $this->getActId());
     $this->adImage->{AdImageFields::FILENAME} = $this->getTestImagePath();
     $this->adImage->save();
     $this->adCreative = new AdCreative(null, $this->getActId());
     $this->adCreative->{AdCreativeFields::TITLE} = 'My Test Ad';
     $this->adCreative->{AdCreativeFields::BODY} = 'My Test Ad Body';
     $this->adCreative->{AdCreativeFields::OBJECT_ID} = $this->getPageId();
     $this->adCreative->{AdCreativeFields::IMAGE_HASH} = $this->adImage->{AdImageFields::HASH};
     $this->adCreative->create();
     $targeting = new TargetingSpecs();
     $targeting->{TargetingSpecsFields::GEO_LOCATIONS} = array('countries' => array('US'));
     $this->adGroup = new AdGroup(null, $this->getActId());
     $this->adGroup->{AdGroupFields::ADGROUP_STATUS} = AdGroup::STATUS_PAUSED;
     $this->adGroup->{AdGroupFields::NAME} = $this->getTestRunId();
     $this->adGroup->{AdGroupFields::BID_TYPE} = AdGroup::BID_TYPE_CPM;
     $this->adGroup->{AdGroupFields::BID_INFO} = array(AdGroupBidInfoFields::IMPRESSIONS => '2');
     $this->adGroup->{AdGroupFields::CAMPAIGN_ID} = (int) $this->adSet->{AdSetFields::ID};
     $this->adGroup->{AdGroupFields::TARGETING} = $targeting;
     $this->adGroup->{AdGroupFields::CREATIVE} = array('creative_id' => $this->adCreative->{AdCreativeFields::ID});
     $this->adGroup->create();
 }
 public function setup()
 {
     parent::setup();
     $targeting = new TargetingSpecs();
     $targeting->{TargetingSpecsFields::GEO_LOCATIONS} = array('countries' => array('US'));
     $this->campaign = new Campaign(null, $this->getConfig()->accountId);
     $this->campaign->{CampaignFields::NAME} = $this->getConfig()->testRunId;
     $this->campaign->create();
     $this->adSet = new AdSet(null, $this->getConfig()->accountId);
     $this->adSet->{AdSetFields::CAMPAIGN_ID} = (int) $this->campaign->{AdSetFields::ID};
     $this->adSet->{AdSetFields::NAME} = $this->getConfig()->testRunId;
     $this->adSet->{AdSetFields::DAILY_BUDGET} = '150';
     $this->adSet->{AdSetFields::START_TIME} = (new \DateTime("+1 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdSetFields::END_TIME} = (new \DateTime("+2 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdFields::TARGETING} = $targeting;
     $this->adSet->{AdSetFields::OPTIMIZATION_GOAL} = OptimizationGoals::REACH;
     $this->adSet->{AdSetFields::BILLING_EVENT} = BillingEvents::IMPRESSIONS;
     $this->adSet->{AdSetFields::BID_AMOUNT} = 2;
     $this->adSet->create(array(AdSet::STATUS_PARAM_NAME => AdSet::STATUS_PAUSED));
     $this->adImage = new AdImage(null, $this->getConfig()->accountId);
     $this->adImage->{AdImageFields::FILENAME} = $this->getConfig()->testImagePath;
     $this->adImage->save();
     $this->adCreative = new AdCreative(null, $this->getConfig()->accountId);
     $this->adCreative->{AdCreativeFields::TITLE} = 'My Test Ad';
     $this->adCreative->{AdCreativeFields::BODY} = 'My Test Ad Body';
     $this->adCreative->{AdCreativeFields::OBJECT_ID} = $this->getConfig()->pageId;
     $this->adCreative->{AdCreativeFields::IMAGE_HASH} = $this->adImage->{AdImageFields::HASH};
     $this->adCreative->create();
     $this->ad = new Ad(null, $this->getConfig()->accountId);
     $this->ad->{AdFields::NAME} = $this->getConfig()->testRunId;
     $this->ad->{AdFields::ADSET_ID} = (int) $this->adSet->{AdSetFields::ID};
     $this->ad->{AdFields::CREATIVE} = array('creative_id' => $this->adCreative->{AdCreativeFields::ID});
     $this->ad->create(array(Ad::STATUS_PARAM_NAME => Ad::STATUS_PAUSED));
 }
 public function setup()
 {
     parent::setup();
     $ca = new CustomAudienceMultiKey(null, $this->getConfig()->accountId);
     $ca->{CustomAudienceFields::NAME} = $this->getConfig()->testRunId;
     $ca->{CustomAudienceFields::SUBTYPE} = CustomAudienceSubtypes::CUSTOM;
     $ca->create();
     $this->customaudience = $ca;
 }
 public function setup()
 {
     parent::setup();
     $page = new Page($this->getConfig()->pageId);
     $forms = $page->getLeadgenForms();
     if ($forms->count() === 0) {
         $this->markTestSkipped(sprintf('LeadgenForms can\'t be created through the API.' . ' Page %s has no leadgen forms', (string) $this->getConfig()->pageId));
     }
     $this->leadgenFormId = $forms->current()->{LeadgenFormFields::ID};
 }
 public function setup()
 {
     parent::setup();
     $this->account = new AdAccount($this->getActId());
     $cursor = $this->account->getAdsPixels();
     $this->adsPixel = $cursor->current();
     $this->productCatalog = new ProductCatalog(null, $this->getBusinessManagerId());
     $this->productCatalog->setData(array(ProductCatalogFields::NAME => 'Test Catalog ' . $this->getTestRunId()));
     $this->productCatalog->create();
     $this->productSet = new ProductSet(null, $this->productCatalog->{ProductCatalogFields::ID});
     $this->productSet->setData(array(ProductSetFields::NAME => 'Test Set ' . $this->getTestRunId(), ProductSetFields::FILTER => array('retailer_id' => array('is_any' => array('pid1', 'pid2')))));
     $this->productSet->create();
 }
 public function setup()
 {
     parent::setup();
     $this->account = new AdAccount($this->getConfig()->accountId);
     $cursor = $this->account->getAdsPixels();
     $this->adsPixel = $cursor->current();
     $this->productCatalog = new ProductCatalog(null, $this->getConfig()->businessId);
     $this->productCatalog->setData(array(ProductCatalogFields::NAME => $this->getConfig()->testRunId));
     $this->productCatalog->create();
     $this->productSet = new ProductSet(null, $this->productCatalog->{ProductCatalogFields::ID});
     $this->productSet->setData(array(ProductSetFields::NAME => $this->getConfig()->testRunId, ProductSetFields::FILTER => array('retailer_id' => array('is_any' => array('pid1', 'pid2')))));
     $this->productSet->create();
 }
 public function setup()
 {
     parent::setup();
     $limit = 25;
     $page = new Page($this->getConfig()->pageId);
     $forms = $page->getLeadgenForms(array(LeadgenFormFields::ID), array('limit' => $limit));
     $forms->setUseImplicitFetch(false);
     // Force-disable pagination
     /** @var LeadgenForm $form */
     foreach ($forms as $form) {
         $leads = $form->getLeads();
         if ($leads->count() > 0) {
             $this->leadId = $leads->current()->{LeadFields::ID};
             break;
         }
     }
     if ($this->leadId === null) {
         $this->markTestSkipped(sprintf('Leads can\'t be created through the API.' . ' The first %d leadgen forms of Page %s have no leads', $limit, (string) $this->getConfig()->pageId));
     }
 }
 public function setup()
 {
     parent::setup();
     $this->adCampaign = new AdCampaign(null, $this->getActId());
     $this->adCampaign->{AdCampaignFields::NAME} = $this->getTestRunId();
     $this->adCampaign->create();
     $this->adSet = new AdSet(null, $this->getActId());
     $this->adSet->{AdSetFields::CAMPAIGN_GROUP_ID} = (int) $this->adCampaign->{AdSetFields::ID};
     $this->adSet->{AdSetFields::NAME} = $this->getTestRunId();
     $this->adSet->{AdSetFields::CAMPAIGN_STATUS} = AdSet::STATUS_PAUSED;
     $this->adSet->{AdSetFields::DAILY_BUDGET} = '150';
     $this->adSet->{AdSetFields::START_TIME} = (new \DateTime("+1 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdSetFields::END_TIME} = (new \DateTime("+2 week"))->format(\DateTime::ISO8601);
     $this->adSet->save();
     $this->adImage = new AdImage(null, $this->getActId());
     $this->adImage->{AdImageFields::FILENAME} = $this->getTestImagePath();
     $this->adImage->save();
     $this->adCreative = new AdCreative(null, $this->getActId());
     $this->adCreative->{AdCreativeFields::TITLE} = 'My Test Ad';
     $this->adCreative->{AdCreativeFields::BODY} = 'My Test Ad Body';
     $this->adCreative->{AdCreativeFields::OBJECT_ID} = $this->getPageId();
     $this->adCreative->create();
 }
 public function setup()
 {
     parent::setup();
     $account = new AdAccount($this->getConfig()->accountId);
     $this->adsPixel = $account->getAdsPixels()->current();
     if ($this->adsPixel === null) {
         throw new \Exception('Ads Pixel is null');
     }
     $this->productCatalog = new ProductCatalog(null, $this->getConfig()->businessId);
     $this->productCatalog->setData(array(ProductCatalogFields::NAME => $this->getConfig()->testRunId));
     $this->productCatalog->create();
     $this->productSet = new ProductSet(null, $this->productCatalog->{ProductCatalogFields::ID});
     $this->productSet->setData(array(ProductSetFields::NAME => $this->getConfig()->testRunId, ProductSetFields::FILTER => array('retailer_id' => array('is_any' => array('pid1', 'pid2')))));
     $this->productSet->create();
     $this->productAudience = new ProductAudience(null, $this->getConfig()->accountId);
     $this->productAudience->setData(array(ProductAudienceFields::NAME => $this->getConfig()->testRunId, ProductAudienceFields::PRODUCT_SET_ID => $this->productSet->{ProductSetFields::ID}, ProductAudienceFields::PIXEL_ID => $this->adsPixel->{AdsPixelsFields::ID}, ProductAudienceFields::INCLUSIONS => array(array('retention_seconds' => 86400, 'rule' => array('and' => array(array('event' => array('eq' => 'ViewContent')), array('userAgent' => array('i_contains' => 'iPhone'))))))));
     $this->productAudience->create();
 }