/**
  * A method to test the run() method.
  */
 function testRun()
 {
     $oServiceLocator =& OA_ServiceLocator::instance();
     $aConf['maintenance']['operationInterval'] = 60;
     // Test 1: Test with the bucket data not having been migrated,
     //         and ensure that the DAL calls to de-duplicate and
     //         reject conversions are not made
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Mock the MSE DAL used to de-duplicate conversions,
     // and set the expectations of the calls to the DAL
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDal->expectNever('manageConversions');
     $oDal->__construct();
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controlling class' status and test
     $oManageConversions = new OX_Maintenance_Statistics_Task_ManageConversions();
     $oManageConversions->oController->updateIntermediate = false;
     $oManageConversions->run();
     $oDal->tally();
     // Test 2: Test with the bucket data having been migrated, and
     //         ensure that the DALL calls to de-duplicate and reject
     //         conversions are made correctly
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Mock the MSE DAL used to de-duplicate conversions,
     // and set the expectations of the calls to the DAL
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDate = new Date('2008-09-08 16:59:59');
     $oDate->addSeconds(1);
     $oDal->expectOnce('manageConversions', array($oDate, new Date('2008-09-08 17:59:59')));
     $oDal->__construct();
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controlling class' status and test
     $oManageConversions = new OX_Maintenance_Statistics_Task_ManageConversions();
     $oManageConversions->oController->updateIntermediate = true;
     $oManageConversions->oController->oLastDateIntermediate = new Date('2008-09-08 16:59:59');
     $oManageConversions->oController->oUpdateIntermediateToDate = new Date('2008-09-08 17:59:59');
     $oManageConversions->run();
     $oDal->tally();
     TestEnv::restoreConfig();
 }
 /**
  * A method to test the run() method.
  */
 function testRun()
 {
     $oServiceLocator =& OA_ServiceLocator::instance();
     // Register the current date/time
     $oDateNow = new Date();
     $oServiceLocator->register('now', $oDateNow);
     // Mock the DAL, and set expectations
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDal->expectNever('manageCampaigns');
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Test
     $oManageCampaigns = new OX_Maintenance_Statistics_Task_ManageCampaigns();
     $oManageCampaigns->oController->updateIntermediate = false;
     $oManageCampaigns->run();
     $oDal->tally();
     // Register the current date/time
     $oDateNow = new Date();
     $oServiceLocator->register('now', $oDateNow);
     // Mock the DAL, and set expectations
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDal->expectOnce('manageCampaigns', array($oDateNow));
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Test
     $oManageCampaigns = new OX_Maintenance_Statistics_Task_ManageCampaigns();
     $oManageCampaigns->oController->updateIntermediate = true;
     $oManageCampaigns->run();
     $oDal->tally();
 }
 /**
  * A method to test the run() method.
  */
 function testRun()
 {
     $oServiceLocator =& OA_ServiceLocator::instance();
     $aTypes = array('types' => array(0 => 'request', 1 => 'impression', 2 => 'click'), 'connections' => array(1 => MAX_CONNECTION_AD_IMPRESSION, 2 => MAX_CONNECTION_AD_CLICK));
     // Mock the DAL, and set expectations
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDal->expectNever('saveSummary');
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Test
     $oSummariseFinal = new OX_Maintenance_Statistics_Task_SummariseFinal();
     $oSummariseFinal->oController->updateIntermediate = false;
     $oSummariseFinal->oController->updateFinal = false;
     $oSummariseFinal->run();
     $oDal->tally();
     // Prepare the dates
     $olastDateIntermediate = new Date('2006-03-09 10:59:59');
     $oStartDate = new Date();
     $oStartDate->copy($olastDateIntermediate);
     $oStartDate->addSeconds(1);
     $oUpdateIntermediateToDate = new Date('2006-03-09 11:59:59');
     // Mock the DAL, and set expectations
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDal->expectNever('saveSummary');
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Test
     $oSummariseFinal = new OX_Maintenance_Statistics_Task_SummariseFinal();
     $oSummariseFinal->oController->updateIntermediate = true;
     $oSummariseFinal->oController->oLastDateIntermediate = $olastDateIntermediate;
     $oSummariseFinal->oController->oUpdateIntermediateToDate = $oUpdateIntermediateToDate;
     $oSummariseFinal->oController->updateFinal = false;
     $oSummariseFinal->run();
     $oDal->tally();
     // Prepare the dates
     $olastDateFinal = new Date('2006-03-09 10:59:59');
     $oStartDate = new Date();
     $oStartDate->copy($olastDateFinal);
     $oStartDate->addSeconds(1);
     $oUpdateFinalToDate = new Date('2006-03-09 11:59:59');
     // Mock the DAL, and set expectations
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDal->expectOnce('saveSummary', array($oStartDate, $oUpdateFinalToDate, $aTypes, 'data_intermediate_ad', 'data_summary_ad_hourly'));
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Test
     $oSummariseFinal = new OX_Maintenance_Statistics_Task_SummariseFinal();
     $oSummariseFinal->oController->updateIntermediate = false;
     $oSummariseFinal->oController->updateFinal = true;
     $oSummariseFinal->oController->oLastDateFinal = $olastDateFinal;
     $oSummariseFinal->oController->oUpdateFinalToDate = $oUpdateFinalToDate;
     $oSummariseFinal->run();
     $oDal->tally();
     // Prepare the dates
     $olastDateIntermediate = new Date('2006-03-09 10:59:59');
     $oStartDate = new Date();
     $oStartDate->copy($olastDateIntermediate);
     $oStartDate->addSeconds(1);
     $oUpdateIntermediateToDate = new Date('2006-03-09 11:59:59');
     $olastDateFinal = new Date('2006-03-09 10:59:59');
     $oStartDate = new Date();
     $oStartDate->copy($olastDateFinal);
     $oStartDate->addSeconds(1);
     $oUpdateFinalToDate = new Date('2006-03-09 11:59:59');
     // Mock the DAL, and set expectations
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDal->expectOnce('saveSummary', array($oStartDate, $oUpdateFinalToDate, $aTypes, 'data_intermediate_ad', 'data_summary_ad_hourly'));
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Test
     $oSummariseFinal = new OX_Maintenance_Statistics_Task_SummariseFinal();
     $oSummariseFinal->oController->updateIntermediate = true;
     $oSummariseFinal->oController->oLastDateIntermediate = $olastDateIntermediate;
     $oSummariseFinal->oController->oUpdateIntermediateToDate = $oUpdateIntermediateToDate;
     $oSummariseFinal->oController->updateFinal = true;
     $oSummariseFinal->oController->oLastDateFinal = $olastDateFinal;
     $oSummariseFinal->oController->oUpdateFinalToDate = $oUpdateFinalToDate;
     $oSummariseFinal->run();
     $oDal->tally();
 }