protected static function loadTestFixtures()
 {
     $fixtures = [];
     $userManager = self::getContainer()->get('fos_user.user_manager');
     $campaignManager = self::getContainer()->get('vifeed.campaign.manager');
     /** @var User $publisher */
     $publisher = $userManager->createUser();
     $publisher->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(100)->setEnabled(true)->setType(User::TYPE_PUBLISHER)->setPlainPassword('12345')->setPhone(1234567);
     $userManager->updateUser($publisher);
     $publisher->setNotification(['sms' => true]);
     $userManager->updateUser($publisher);
     /** @var User $advertiser */
     $advertiser = $userManager->createUser();
     $advertiser->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(100)->setEnabled(true)->setType(User::TYPE_ADVERTISER)->setPlainPassword('12345');
     $userManager->updateUser($advertiser);
     $campaign0 = new Campaign();
     $campaign0->setStatus(Campaign::STATUS_ON)->setBid(3)->setName('000campaign')->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser)->setDailyBudget(10)->setGeneralBudget(60);
     $campaignManager->save($campaign0);
     $campaign1 = new Campaign();
     $campaign1->setStatus(Campaign::STATUS_ON)->setBid(3)->setName('111campaign')->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser)->setDailyBudget(0)->setGeneralBudget(500);
     $campaignManager->save($campaign1);
     $fixtures = ['publisher' => $publisher, 'advertiser' => $advertiser, 'campaigns' => [$campaign0, $campaign1]];
     return $fixtures;
 }
 /**
  * @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]);
 }
示例#3
0
 protected static function loadTestFixtures()
 {
     $campaignManager = self::getContainer()->get('vifeed.campaign.manager');
     $tagManager = self::getContainer()->get('vifeed.tag.manager');
     $userManager = self::getContainer()->get('fos_user.user_manager');
     $tokenManager = static::getContainer()->get('vifeed.user.wsse_token_manager');
     $tag1 = $tagManager->loadOrCreateTag('ааа');
     $tag2 = $tagManager->loadOrCreateTag('ббб');
     /** @var User $advertiser */
     $advertiser = $userManager->createUser();
     $advertiser->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(100)->setEnabled(true)->setType(User::TYPE_ADVERTISER)->setPlainPassword('12345');
     $userManager->updateUser($advertiser);
     $campaign1 = new Campaign();
     $campaign1->setStatus(Campaign::STATUS_ARCHIVED)->setBid(3)->setName('111')->setUser($advertiser)->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setDailyBudget(7)->setGeneralBudget(10);
     $campaignManager->save($campaign1);
     $tagManager->addTags([$tag1, $tag2], $campaign1);
     $tagManager->saveTagging($campaign1);
     $tokenManager->createUserToken($advertiser->getId());
     return ['advertiser' => $advertiser, 'campaign' => $campaign1];
 }
示例#4
0
 /**
  *
  * @return array
  */
 protected static function loadTestFixtures()
 {
     /** @var UserManager $userManager */
     $userManager = self::getContainer()->get('fos_user.user_manager');
     /** @var EntityManager $entityManager */
     $entityManager = self::$em;
     $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(26)->setEnabled(true)->setType(User::TYPE_ADVERTISER)->setPlainPassword('12345');
     $userManager->updateUser($advertiser, false);
     /** @var User $publisher */
     $publisher = $userManager->createUser();
     $publisher->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(0)->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($advertiser)->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setDailyBudget(6)->setGeneralBudget(10)->setBalance(10);
     $campaignManager->save($campaign1);
     $campaign2 = new Campaign();
     $campaign2->setStatus(Campaign::STATUS_ON)->setBid(3)->setName('222')->setUser($advertiser)->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setDailyBudget(0)->setGeneralBudget(10)->setBalance(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($advertiser)->setDailyBudget(10)->setGeneralBudget(100)->setBalance(100);
     $campaignManager->save($campaign3);
     $campaign4 = new Campaign();
     $campaign4->setStatus(Campaign::STATUS_ON)->setBid(3)->setName('444')->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setUser($advertiser)->setDailyBudget(0)->setGeneralBudget(100)->setBalance(100);
     $campaignManager->save($campaign4);
     $platform = new Platform();
     $platform->setName('campaignStatusTestPlatform')->setUser($publisher)->setUrl('')->setDescription('');
     $entityManager->persist($platform);
     $entityManager->flush();
     $tokenManager->createUserToken($advertiser->getId());
     return array('advertiser' => $advertiser, 'publisher' => $publisher, 'platform' => $platform, 'campaigns' => array($campaign1, $campaign2, $campaign3, $campaign4));
 }
示例#5
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]);
 }
示例#6
0
 /**
  * @param \Vifeed\CampaignBundle\Entity\Campaign $campaign
  */
 private function turnOn(Campaign $campaign)
 {
     $campaign->setStatus(Campaign::STATUS_ON)->setStartAt(new \DateTime());
 }
示例#7
0
 protected static function loadTestFixtures()
 {
     /** @var UserManager $userManager */
     $userManager = self::getContainer()->get('fos_user.user_manager');
     /** @var EntityManager $entityManager */
     $entityManager = self::$em;
     $campaignManager = self::getContainer()->get('vifeed.campaign.manager');
     $tokenManager = static::getContainer()->get('vifeed.user.wsse_token_manager');
     /** @var VideoViewPaymentManager $viewPaymentManager */
     $viewPaymentManager = self::getContainer()->get('vifeed.payment.video_view_payment_manager');
     $paymentPluginController = self::getContainer()->get('payment.plugin_controller');
     /** @var StatsManager $statsManager */
     $statsManager = self::getContainer()->get('vifeed.videoview.stats_manager');
     /** @var User $advertiser */
     $advertiser = $userManager->createUser();
     $advertiser->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(26)->setEnabled(true)->setType(User::TYPE_ADVERTISER)->setPlainPassword('12345');
     $userManager->updateUser($advertiser, false);
     /** @var User $publisher */
     $publisher = $userManager->createUser();
     $publisher->setEmail('*****@*****.**')->setUsername('*****@*****.**')->setBalance(200)->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($advertiser)->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setDailyBudget(7)->setBalance(10)->setGeneralBudget(10);
     $campaignManager->save($campaign1);
     $campaign2 = new Campaign();
     $campaign2->setStatus(Campaign::STATUS_ON)->setBid(3)->setName('222')->setUser($advertiser)->setHash(substr(md5(mt_rand(1, 100)), 0, 11))->setDailyBudget(0)->setBalance(10)->setGeneralBudget(10)->setDeletedAt(new \DateTime('2014-02-10'));
     $campaignManager->save($campaign2);
     $platform1 = new Platform();
     $platform1->setName('111')->setUser($publisher)->setUrl('111')->setDescription('');
     $entityManager->persist($platform1);
     // плолщадка удалена (soft-delete)
     $platform2 = new Platform();
     $platform2->setName('222')->setUser($publisher)->setUrl('222')->setDescription('')->setDeletedAt(new \DateTime('2014-02-10'));
     $entityManager->persist($platform2);
     $view1 = new VideoView();
     $view1->setCampaign($campaign1)->setPlatform($platform1)->setCurrentTime(60)->setTimestamp((new \DateTime('2014-02-22 00:00:00'))->format('U'))->setTrackNumber(60)->setViewerId(md5(1));
     $entityManager->persist($view1);
     $entityManager->flush();
     $viewPaymentManager->reckon($view1);
     $view2 = new VideoView();
     $view2->setCampaign($campaign1)->setPlatform($platform2)->setCurrentTime(60)->setTimestamp((new \DateTime('2014-02-23 00:00:00'))->format('U'))->setTrackNumber(60)->setViewerId(md5(2));
     $entityManager->persist($view2);
     $entityManager->flush();
     $viewPaymentManager->reckon($view2);
     $view3 = new VideoView();
     $view3->setCampaign($campaign2)->setPlatform($platform1)->setCurrentTime(60)->setTimestamp((new \DateTime('2014-02-23 23:00:00'))->format('U'))->setTrackNumber(60)->setViewerId(md5(3));
     $entityManager->persist($view3);
     $entityManager->flush();
     $viewPaymentManager->reckon($view3);
     $view4 = new VideoView();
     $view4->setCampaign($campaign2)->setPlatform($platform1)->setCurrentTime(60)->setTimestamp((new \DateTime('2014-02-23 23:29:59'))->format('U'))->setTrackNumber(60)->setViewerId(md5(4));
     $entityManager->persist($view4);
     $entityManager->flush();
     $viewPaymentManager->reckon($view4);
     $view5 = new VideoView();
     $view5->setCampaign($campaign2)->setPlatform($platform1)->setCurrentTime(60)->setTimestamp((new \DateTime('2014-02-23 23:59:59'))->format('U'))->setTrackNumber(60)->setViewerId(md5(4));
     $entityManager->persist($view5);
     $entityManager->flush();
     $viewPaymentManager->reckon($view5);
     $instruction1 = new PaymentInstruction(100, 'RUR', 'robokassa');
     $paymentPluginController->createPaymentInstruction($instruction1);
     $instruction2 = new PaymentInstruction(50, 'RUR', 'robokassa');
     $paymentPluginController->createPaymentInstruction($instruction2);
     $instruction3 = new PaymentInstruction(50, 'RUR', 'robokassa');
     $paymentPluginController->createPaymentInstruction($instruction3);
     $order1 = new Order();
     $order1->setUser($advertiser)->setStatus(Order::STATUS_PAID)->setAmount(100)->setPaymentInstruction($instruction1);
     $entityManager->persist($order1);
     $order2 = new Order();
     $order2->setUser($advertiser)->setStatus(Order::STATUS_PAID)->setAmount(50)->setPaymentInstruction($instruction2);
     $entityManager->persist($order2);
     $order3 = new Order();
     $order3->setUser($advertiser)->setStatus(Order::STATUS_NEW)->setAmount(50)->setPaymentInstruction($instruction3);
     $entityManager->persist($order3);
     $wallet = new Wallet();
     $wallet->setUser($publisher)->setNumber(12345)->setType('yandex');
     $entityManager->persist($wallet);
     $withdrawal1 = new Withdrawal();
     $withdrawal1->setUser($publisher)->setAmount(50)->setWallet($wallet)->setCreatedAt(new \DateTime('2014-02-28 10:00:00'))->setStatus(Withdrawal::STATUS_OK);
     $entityManager->persist($withdrawal1);
     $withdrawal2 = new Withdrawal();
     $withdrawal2->setUser($publisher)->setAmount(100)->setWallet($wallet)->setCreatedAt(new \DateTime('2014-02-28 12:00:00'))->setStatus(Withdrawal::STATUS_OK);
     $entityManager->persist($withdrawal2);
     $withdrawal3 = new Withdrawal();
     $withdrawal3->setUser($publisher)->setAmount(20)->setWallet($wallet)->setCreatedAt(new \DateTime('2014-02-27 10:00:00'))->setStatus(Withdrawal::STATUS_CREATED);
     $entityManager->persist($withdrawal3);
     $withdrawal4 = new Withdrawal();
     $withdrawal4->setUser($publisher)->setAmount(30)->setWallet($wallet)->setCreatedAt(new \DateTime('2014-02-27 11:00:00'))->setStatus(Withdrawal::STATUS_ERROR);
     $entityManager->persist($withdrawal4);
     $entityManager->flush();
     $tokenManager->createUserToken($advertiser->getId());
     $tokenManager->createUserToken($publisher->getId());
     $statsManager->recollectAllStats();
     $statsManager->collectDailyStats((new \DateTime())->setTime(0, 0, 0));
     return array('advertiser' => $advertiser, 'publisher' => $publisher, 'platforms' => [$platform1, $platform2], 'campaigns' => array($campaign1, $campaign2));
 }