protected static function loadTestFixtures()
 {
     $fixtures = parent::loadTestFixtures();
     /** @var EntityManager $entityManager */
     $entityManager = self::$em;
     /** @var VideoViewPaymentManager $viewPaymentManager */
     $viewPaymentManager = self::getContainer()->get('vifeed.payment.video_view_payment_manager');
     /** @var StatsManager $statsManager */
     $statsManager = self::getContainer()->get('vifeed.videoview.stats_manager');
     $platform = new Platform();
     $platform->setName('111')->setUser($fixtures['publisher'])->setUrl('111')->setDescription('');
     $entityManager->persist($platform);
     $city1 = new City();
     $city1->setName('Москва')->setCountry($fixtures['countries'][0])->setLatitude('111.111')->setLongitude('111.222');
     $entityManager->persist($city1);
     $city2 = new City();
     $city2->setName('Воронеж')->setCountry($fixtures['countries'][0])->setLatitude('222.222')->setLongitude('222.333');
     $entityManager->persist($city2);
     $view1 = new VideoView();
     $view1->setCampaign($fixtures['campaigns'][0])->setPlatform($platform)->setCurrentTime(10)->setTimestamp((new \DateTime('yesterday'))->setTime(0, 0, 0)->format('U'))->setCountry($fixtures['countries'][0])->setCity($city1)->setTrackNumber(10)->setViewerId(md5(1));
     $entityManager->persist($view1);
     $entityManager->flush($view1);
     $viewPaymentManager->reckon($view1);
     $view2 = new VideoView();
     $view2->setCampaign($fixtures['campaigns'][0])->setPlatform($platform)->setCurrentTime(60)->setTimestamp((new \DateTime('yesterday'))->setTime(0, 0, 0)->format('U'))->setCountry($fixtures['countries'][0])->setCity($city1)->setTrackNumber(60)->setViewerId(md5(2));
     $entityManager->persist($view2);
     $entityManager->flush($view2);
     $viewPaymentManager->reckon($view2);
     $view3 = new VideoView();
     $view3->setCampaign($fixtures['campaigns'][0])->setPlatform($platform)->setCurrentTime(60)->setTimestamp((new \DateTime('yesterday'))->setTime(23, 0, 0)->format('U'))->setCountry($fixtures['countries'][0])->setCity($city2)->setTrackNumber(60)->setViewerId(md5(3));
     $entityManager->persist($view3);
     $entityManager->flush($view3);
     $viewPaymentManager->reckon($view3);
     $view4 = new VideoView();
     $view4->setCampaign($fixtures['campaigns'][0])->setPlatform($platform)->setCurrentTime(60)->setTimestamp((new \DateTime('today'))->setTime(23, 29, 59)->format('U'))->setCountry($fixtures['countries'][1])->setTrackNumber(60)->setViewerId(md5(4));
     $entityManager->persist($view4);
     $entityManager->flush($view4);
     $viewPaymentManager->reckon($view4);
     $view5 = new VideoView();
     $view5->setCampaign($fixtures['campaigns'][0])->setPlatform($platform)->setCurrentTime(60)->setTimestamp((new \DateTime('today'))->setTime(23, 59, 59)->format('U'))->setCountry($fixtures['countries'][1])->setTrackNumber(60)->setViewerId(md5(4));
     $entityManager->persist($view5);
     $entityManager->flush($view5);
     $viewPaymentManager->reckon($view5);
     $entityManager->flush();
     $statsManager->recollectAllStats();
     $statsManager->collectDailyStats((new \DateTime())->setTime(0, 0, 0));
     $fixtures['cities'] = [$city1, $city2];
     $fixtures['platform'] = $platform;
     return $fixtures;
 }
 protected static function loadTestFixtures()
 {
     $fixtures = parent::loadTestFixtures();
     /** @var EntityManager $entityManager */
     $entityManager = self::$em;
     /** @var VideoViewPaymentManager $viewPaymentManager */
     $viewPaymentManager = self::getContainer()->get('vifeed.payment.video_view_payment_manager');
     $platform1 = new Platform();
     $platform1->setName('111')->setUser($fixtures['publisher'])->setUrl('111')->setDescription('');
     $entityManager->persist($platform1);
     $view1 = new VideoView();
     $view1->setCampaign($fixtures['campaigns'][2])->setPlatform($platform1)->setCurrentTime(60)->setTimestamp((new \DateTime('2014-03-22'))->format('U'))->setTrackNumber(60)->setViewerId(md5(1));
     $entityManager->persist($view1);
     $viewPaymentManager->reckon($view1);
     $view2 = new VideoView();
     $view2->setCampaign($fixtures['campaigns'][2])->setPlatform($platform1)->setCurrentTime(60)->setTimestamp((new \DateTime('2014-03-23'))->format('U'))->setTrackNumber(60)->setViewerId(md5(2));
     $entityManager->persist($view2);
     $viewPaymentManager->reckon($view2);
     $view3 = new VideoView();
     $view3->setCampaign($fixtures['campaigns'][1])->setPlatform($platform1)->setCurrentTime(60)->setTimestamp((new \DateTime('2014-03-23'))->format('U'))->setTrackNumber(60)->setViewerId(md5(3));
     $entityManager->persist($view3);
     $viewPaymentManager->reckon($view3);
     $view4 = new VideoView();
     $view4->setCampaign($fixtures['campaigns'][1])->setPlatform($platform1)->setCurrentTime(10)->setTimestamp((new \DateTime('2014-03-23'))->format('U'))->setTrackNumber(10)->setViewerId(md5(4));
     $entityManager->persist($view4);
     $viewPaymentManager->reckon($view4);
     self::$em->refresh($fixtures['campaigns'][1]);
     self::$em->refresh($fixtures['campaigns'][2]);
     return $fixtures;
 }