Ejemplo n.º 1
0
 public static function genStatsReport()
 {
     $stats_report = new \ebussola\ads\reports\statsreport\StatsReport();
     $size = rand(50, 200);
     for ($i = 0; $i <= $size; $i++) {
         $stats_report->addStats(self::genStats());
     }
     $stats_report = new \ebussola\ads\reports\adwords\statsreport\StatsReport($stats_report);
     $stats_report->refreshValues();
     return $stats_report;
 }
 public function testAveragePosition()
 {
     $stats_report = new \ebussola\ads\reports\statsreport\StatsReport();
     for ($i = 0; $i <= 100; $i++) {
         $stats = new \stdClass();
         $stats->avgPosition = rand(3, 5);
         $stats = new \ebussola\ads\reports\adwords\stats\AbstractStats($stats);
         $stats_report->addStats($stats);
     }
     $stats_report = new \ebussola\ads\reports\adwords\statsreport\StatsReport($stats_report);
     $stats_report->refreshValues();
     $this->assertLessThanOrEqual(5, $stats_report->average_position);
     $this->assertGreaterThanOrEqual(3, $stats_report->average_position);
 }
Ejemplo n.º 3
0
 /**
  * @param array $data
  * @param       $stats_class
  * The stats class name
  *
  * @return StatsReport
  */
 protected function abstractMakeReport(array $data, $stats_class)
 {
     $stats_report = new \ebussola\ads\reports\statsreport\StatsReport();
     $stats_report = new \ebussola\ads\reports\adwords\statsreport\StatsReport($stats_report);
     foreach ($data as $stats) {
         $stats = new $stats_class($stats);
         /** @noinspection PhpUndefinedMethodInspection */
         $stats->refreshValues();
         $stats_report->addStats($stats);
     }
     return $stats_report;
 }