/** * Test zones CR statistics. * */ function testGetZonesConversionRateStatistics() { $doCampaign1 = null; $doCampaign2 = null; $doZone1 = null; $doZone2 = null; $doDataSummaryAdHourly1 = null; $doDataSummaryAdHourly2 = null; $doDataSummaryAdHourly3 = null; $this->_generateDataForPerformanceStatisticsTests($doCampaign1, $doCampaign2, $doZone1, $doZone2, $doDataSummaryAdHourly1, $doDataSummaryAdHourly2, $doDataSummaryAdHourly3); // Get statistics for 2 zones $rsZonesStatistics = $this->_dalZoneStatistics->getZonesConversionRateStatistics(array($doZone1->zoneid, $doZone2->zoneid), new Date('2008-04-27'), new Date('2008-05-27')); $rsZonesStatistics->find(); $this->assertTrue($rsZonesStatistics->getRowCount() == 2, '2 records should be returned'); $rsZonesStatistics->fetch(); $aRow1 = $rsZonesStatistics->toArray(); $rsZonesStatistics->fetch(); $aRow2 = $rsZonesStatistics->toArray(); $this->ensureRowSequence($aRow1, $aRow2, 'zone_id', $doZone1->zoneid); $this->assertFieldExists($aRow1, 'zone_id'); $this->assertFieldExists($aRow1, 'conversions'); $this->assertFieldExists($aRow1, 'impressions'); $this->assertFieldExists($aRow2, 'zone_id'); $this->assertFieldExists($aRow2, 'conversions'); $this->assertFieldExists($aRow2, 'impressions'); $this->assertFieldEqual($aRow1, 'conversions', $doDataSummaryAdHourly1->conversions); $this->assertFieldEqual($aRow1, 'impressions', $doDataSummaryAdHourly1->impressions); $this->assertFieldEqual($aRow2, 'conversions', $doDataSummaryAdHourly3->conversions); $this->assertFieldEqual($aRow2, 'impressions', $doDataSummaryAdHourly3->impressions); // Get statistics for 2 zones and campaign 2 (CPM) $rsZonesStatistics = $this->_dalZoneStatistics->getZonesConversionRateStatistics(array($doZone1->zoneid, $doZone2->zoneid), new Date('2008-04-27'), new Date('2008-05-27'), $doCampaign2->campaignid); $rsZonesStatistics->find(); $this->assertTrue($rsZonesStatistics->getRowCount() == 0, 'Recordset should be empty'); // Get statistics for zone 2 and set start date that it didn't catch any stats for this zone $rsZonesStatistics = $this->_dalZoneStatistics->getZonesConversionRateStatistics(array($doZone2->zoneid), new Date('2008-05-16'), new Date('2008-06-16')); $rsZonesStatistics->find(); $this->assertTrue($rsZonesStatistics->getRowCount() == 0, 'Recordset should be empty'); }