Пример #1
0
 protected static function loadTestFixtures()
 {
     $country1 = new Country();
     $country1->setName('Россия');
     self::$em->persist($country1);
     $country2 = new Country();
     $country2->setName('Белоруссия');
     self::$em->persist($country2);
     self::$em->flush();
     return ['countries' => [$country1, $country2]];
 }
Пример #2
0
 protected static function loadTestFixtures()
 {
     $country1 = new Country();
     $country1->setName('Россия');
     self::$em->persist($country1);
     $country2 = new Country();
     $country2->setName('Белоруссия');
     self::$em->persist($country2);
     $city1 = new City();
     $city1->setCountry($country1)->setName('Москва');
     self::$em->persist($city1);
     $city2 = new City();
     $city2->setCountry($country1)->setName('Санкт-Петербург');
     self::$em->persist($city2);
     self::$em->flush();
     return ['countries' => [$country1, $country2]];
 }
 /**
  * @return array
  */
 protected static function loadTestFixtures()
 {
     $userManager = self::getContainer()->get('fos_user.user_manager');
     /** @var EntityManager $entityManager */
     $entityManager = self::getContainer()->get('doctrine.orm.entity_manager');
     $campaignManager = self::getContainer()->get('vifeed.campaign.manager');
     $tokenManager = static::getContainer()->get('vifeed.user.wsse_token_manager');
     /** @var User $advertiser */
     $advertiser = $userManager->createUser();
     $advertiser->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(100)->setEnabled(true)->setType(User::TYPE_ADVERTISER)->setPlainPassword('12345');
     $userManager->updateUser($advertiser, false);
     /** @var User $publisher */
     $publisher = $userManager->createUser();
     $publisher->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(100)->setEnabled(true)->setType(User::TYPE_PUBLISHER)->setPlainPassword('12345');
     $userManager->updateUser($publisher, false);
     $platform = new Platform();
     $platform->setUser($publisher)->setName('name1')->setDescription('111')->setUrl('url1');
     $entityManager->persist($platform);
     $country1 = new Country();
     $country1->setName('Россия');
     $entityManager->persist($country1);
     $country2 = new Country();
     $country2->setName('США');
     $entityManager->persist($country2);
     $campaign1 = new Campaign();
     $campaign1->setStatus(Campaign::STATUS_ON)->setBid(3)->setName('111')->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser)->setDailyBudget(10)->setGeneralBudget(100)->setBalance(100)->addCountry($country1);
     $campaignManager->save($campaign1);
     // удалённая кампания
     $campaign2 = new Campaign();
     $campaign2->setStatus(Campaign::STATUS_ON)->setBid(3)->setName('222')->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser)->setDailyBudget(10)->setGeneralBudget(100)->setBalance(100)->setDeletedAt(new \DateTime('2014-02-10'));
     $campaignManager->save($campaign2);
     $campaigns = [$campaign1, $campaign2];
     for ($i = 0; $i < 14; $i++) {
         $campaign = new Campaign();
         $campaign->setStatus(Campaign::STATUS_ON)->setBid(3)->setName(md5($i))->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser)->setDailyBudget(10)->setBalance(100)->setGeneralBudget(100);
         if ($i < 10) {
             $campaign->addCountry($country2);
         }
         $campaignManager->save($campaign);
         $campaigns[] = $campaign;
     }
     $entityManager->flush();
     $tokenManager->createUserToken($publisher->getId());
     return array('advertiser' => $advertiser, 'publisher' => $publisher, 'campaigns' => $campaigns, 'platforms' => [$platform], 'countries' => [$country1, $country2]);
 }
Пример #4
0
 /**
  * @return array
  */
 protected static function loadTestFixtures()
 {
     $userManager = self::getContainer()->get('fos_user.user_manager');
     /** @var EntityManager $entityManager */
     $entityManager = self::getContainer()->get('doctrine.orm.entity_manager');
     $campaignManager = self::getContainer()->get('vifeed.campaign.manager');
     $tokenManager = static::getContainer()->get('vifeed.user.wsse_token_manager');
     $country1 = new Country();
     $country1->setName('Россия');
     $entityManager->persist($country1);
     $country2 = new Country();
     $country2->setName('Белоруссия');
     $entityManager->persist($country2);
     /** @var User $advertiser1 */
     $advertiser1 = $userManager->createUser();
     $advertiser1->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(100)->setEnabled(true)->setType(User::TYPE_ADVERTISER)->setPlainPassword('12345');
     $userManager->updateUser($advertiser1, false);
     /** @var User $advertiser2 */
     $advertiser2 = $userManager->createUser();
     $advertiser2->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(200)->setEnabled(true)->setType(User::TYPE_ADVERTISER)->setPlainPassword('12345');
     $userManager->updateUser($advertiser2, false);
     /** @var User $advertiser3 */
     $advertiser3 = $userManager->createUser();
     $advertiser3->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(100)->setEnabled(true)->setType(User::TYPE_ADVERTISER)->setPlainPassword('12345');
     $userManager->updateUser($advertiser3, false);
     /** @var User $advertiser4 */
     $advertiser4 = $userManager->createUser();
     $advertiser4->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(1)->setEnabled(true)->setType(User::TYPE_ADVERTISER)->setPlainPassword('12345');
     $userManager->updateUser($advertiser4, false);
     /** @var User $publisher */
     $publisher = $userManager->createUser();
     $publisher->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(100)->setEnabled(true)->setType(User::TYPE_PUBLISHER)->setPlainPassword('12345');
     $userManager->updateUser($publisher, false);
     $campaign1 = new Campaign();
     $campaign1->setStatus(Campaign::STATUS_ON)->setBid(3)->setName('111')->setUser($advertiser1)->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setDailyBudget(7)->setStartAt(new \DateTime('-2 day'))->setBalance(10)->setGeneralBudget(10);
     $campaignManager->save($campaign1);
     $campaign2 = new Campaign();
     $campaign2->setStatus(Campaign::STATUS_AWAITING)->setBid(3)->setName('222')->setUser($advertiser2)->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setDailyBudget(0)->setBalance(10)->setGeneralBudget(10);
     $campaignManager->save($campaign2);
     $campaign3 = new Campaign();
     $campaign3->setStatus(Campaign::STATUS_ON)->setBid(3)->setName('333')->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser2)->setDailyBudget(10)->setStartAt(new \DateTime())->setBalance(10)->setGeneralBudget(10);
     $campaignManager->save($campaign3);
     $campaign4 = new Campaign();
     $campaign4->setStatus(Campaign::STATUS_PAUSED)->setBid(3)->setBalance(91)->setName('444')->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser2)->setDailyBudget(10)->setGeneralBudget(100)->updateDailyBudgetUsed(9);
     $campaignManager->save($campaign4);
     $campaign5 = new Campaign();
     $campaign5->setStatus(Campaign::STATUS_AWAITING)->setBid(3)->setName('555')->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser2)->setDailyBudget(10)->setGeneralBudget(4);
     $campaignManager->save($campaign5);
     $campaign6 = new Campaign();
     $campaign6->setStatus(Campaign::STATUS_ARCHIVED)->setBid(3)->setName('666campaign')->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser2)->setDailyBudget(10)->setGeneralBudget(60);
     $campaignManager->save($campaign6);
     // удалённая кампания (soft-delete)
     $campaign7 = new Campaign();
     $campaign7->setStatus(Campaign::STATUS_ON)->setBid(3)->setName('777')->setHash('0123456789a')->setUser($advertiser2)->setDailyBudget(10)->setGeneralBudget(0)->setDeletedAt(new \DateTime('2014-02-10'));
     $campaignManager->save($campaign7);
     $campaign8 = new Campaign();
     $campaign8->setStatus(Campaign::STATUS_AWAITING)->setBid(3)->setName('888')->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser3)->setDailyBudget(0)->setGeneralBudget(15)->updateDailyBudgetUsed(15)->setBalance(10);
     $campaignManager->save($campaign8);
     $campaign9 = new Campaign();
     $campaign9->setStatus(Campaign::STATUS_ENDED)->setBid(3)->setName('999')->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser4)->setDailyBudget(0)->setGeneralBudget(15)->updateDailyBudgetUsed(15);
     $campaignManager->save($campaign9);
     $entityManager->flush();
     $tokenManager->createUserToken($advertiser1->getId());
     $tokenManager->createUserToken($advertiser2->getId());
     $tokenManager->createUserToken($advertiser3->getId());
     $tokenManager->createUserToken($advertiser4->getId());
     $tokenManager->createUserToken($publisher->getId());
     return array('advertisers' => [$advertiser1, $advertiser2, $advertiser3, $advertiser4], 'publisher' => $publisher, 'campaigns' => [$campaign1, $campaign2, $campaign3, $campaign4, $campaign5, $campaign6, $campaign7, $campaign8, $campaign9], 'countries' => [$country1, $country2]);
 }