Example #1
0
 public function testPurgeStatsOnRefresh()
 {
     $stats_report = StatsGen::genStatsReport();
     $stats_report2 = clone $stats_report;
     $stats_report2->refreshValues();
     $this->assertEquals($stats_report->clicks, $stats_report2->clicks);
     $this->assertEquals($stats_report->impressions, $stats_report2->impressions);
     $this->assertEquals($stats_report->cost, $stats_report2->cost);
     $this->assertEquals($stats_report->cpc, $stats_report2->cpc);
     $this->assertEquals($stats_report->ctr, $stats_report2->ctr);
 }
Example #2
0
 public function testGroupByHour()
 {
     $stats_reports = array();
     $stats_reports[1] = StatsGen::genStatsReportHourRange(new DateTime('2013-10-01'), new DateTime('2013-10-30'));
     $stats_reports[2] = StatsGen::genStatsReportHourRange(new DateTime('2013-10-01'), new DateTime('2013-10-30'));
     $stats_reports[3] = StatsGen::genStatsReportHourRange(new DateTime('2013-10-01'), new DateTime('2013-10-30'));
     $stats_reports[4] = StatsGen::genStatsReportHourRange(new DateTime('2013-09-01'), new DateTime('2013-09-30'));
     $stats_reports[5] = StatsGen::genStatsReportHourRange(new DateTime('2013-09-01'), new DateTime('2013-09-30'));
     $stats_reports[6] = StatsGen::genStatsReportHourRange(new DateTime('2013-09-01'), new DateTime('2013-09-30'));
     $main_report = new \ebussola\ads\reports\statsreport\StatsReport();
     foreach ($stats_reports as $stats_report) {
         foreach ($stats_report as $stats) {
             $main_report->addStats($stats);
         }
     }
     $this->assertCount(4173, $main_report->stats);
     $this->reports->groupBy('hour', $main_report);
     $this->assertCount(24, $main_report->stats);
 }
 public function testRefreshValues()
 {
     $stats_report = StatsGen::genStatsReport();
     $stats_report2 = clone $stats_report;
     $stats_report->refreshValues();
     $this->assertNotNull($stats_report->conversions);
     $this->assertNotNull($stats_report->conversion_rate);
     $this->assertNotNull($stats_report->cost_per_conversion);
     $this->assertNotNull($stats_report->conversions_many_per_click);
     $this->assertNotNull($stats_report->conversion_rate_many_per_click);
     $this->assertNotNull($stats_report->cost_per_conversion_many_per_click);
     $this->assertNotNull($stats_report->view_through_conversion);
     $this->assertNotNull($stats_report2->conversions);
     $this->assertNotNull($stats_report2->conversion_rate);
     $this->assertNotNull($stats_report2->cost_per_conversion);
     $this->assertNotNull($stats_report2->conversions_many_per_click);
     $this->assertNotNull($stats_report2->conversion_rate_many_per_click);
     $this->assertNotNull($stats_report2->cost_per_conversion_many_per_click);
     $this->assertNotNull($stats_report2->view_through_conversion);
     $this->assertEquals($stats_report->conversions, $stats_report2->conversions);
     $this->assertEquals($stats_report->conversion_rate, $stats_report2->conversion_rate);
     $this->assertEquals($stats_report->cost_per_conversion, $stats_report2->cost_per_conversion);
     $this->assertEquals($stats_report->conversions_many_per_click, $stats_report2->conversions_many_per_click);
     $this->assertEquals($stats_report->conversion_rate_many_per_click, $stats_report2->conversion_rate_many_per_click);
     $this->assertEquals($stats_report->cost_per_conversion_many_per_click, $stats_report2->cost_per_conversion_many_per_click);
     $this->assertEquals($stats_report->view_through_conversion, $stats_report2->view_through_conversion);
 }