/**
  * A method to test the getAdLifetimeZoneImpressionsRemaining() method.
  *
  * Test 1: Test with invalid parameters, and ensure that zero is returned.
  * Test 2: Test with equal start and end dates, and ensure just that OI's
  *         data is returned.
  * Test 3: Test with a small range of dates in one week, that the correct
  *         sum is returned.
  * Test 4: Test with a small range of dates over three days, covering two
  *         weeks, and ensure that the correct result is returned.
  * Test 5: Test with a limitation that blocks less than 50% of the remaining
  *         range, and ensure that the correct result is returned.
  * Test 6: Test with a limitation that blocks more than 50% of the remaining
  *         range, and ensure that the correct result is returned.
  */
 function testGetAdLifetimeZoneImpressionsRemaining()
 {
     $aConf =& $GLOBALS['_MAX']['CONF'];
     $aConf['maintenance']['operationInterval'] = 60;
     $aDeliveryLimitations = array();
     $oDeliveryLimitationManager = new OA_Maintenance_Priority_DeliveryLimitation($aDeliveryLimitations);
     // Test 1
     $oDate = new Date('2006-02-15 11:07:15');
     $aCumulativeZoneForecast = array();
     $aCumulativeZoneForecast = $this->_fillForecastArray($aCumulativeZoneForecast);
     $result = $oDeliveryLimitationManager->getAdLifetimeZoneImpressionsRemaining('foo', $oDate, $aCumulativeZoneForecast);
     $this->assertEqual($result, 0);
     $result = $oDeliveryLimitationManager->getAdLifetimeZoneImpressionsRemaining($oDate, 'foo', $aCumulativeZoneForecast);
     $this->assertEqual($result, 0);
     $result = $oDeliveryLimitationManager->getAdLifetimeZoneImpressionsRemaining($oDate, $oDate, 'foo');
     $this->assertEqual($result, 0);
     // Test 2
     $oDate = new Date('2006-02-15 23:07:15');
     $aCumulativeZoneForecast = array();
     $aCumulativeZoneForecast = $this->_fillForecastArray($aCumulativeZoneForecast);
     $result = $oDeliveryLimitationManager->getAdLifetimeZoneImpressionsRemaining($oDate, $oDate, $aCumulativeZoneForecast);
     $this->assertEqual($result, 1);
     $aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oDate);
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID($aDates['start']);
     $aCumulativeZoneForecast[$operationIntervalID] = 50;
     $previousOperationIntervalId = OX_OperationInterval::previousOperationIntervalID($operationIntervalID);
     $aCumulativeZoneForecast[$previousOperationIntervalId] = 5;
     $nextOperationIntervalId = OX_OperationInterval::nextOperationIntervalID($operationIntervalID);
     $aCumulativeZoneForecast[$nextOperationIntervalId] = 7;
     $aCumulativeZoneForecast = $this->_fillForecastArray($aCumulativeZoneForecast);
     $result = $oDeliveryLimitationManager->getAdLifetimeZoneImpressionsRemaining($oDate, $oDate, $aCumulativeZoneForecast);
     $this->assertEqual($result, 50);
     // Test 3
     $oStartDate = new Date('2006-02-15 11:07:15');
     $oEndDate = new Date('2006-02-15 23:59:59');
     $aCumulativeZoneForecast = array();
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 10:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 1;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 11:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 10;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 12:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 100;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 13:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 1000;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 14:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 10000;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 15:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 100000;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 16:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 1000000;
     $aCumulativeZoneForecast = $this->_fillForecastArray($aCumulativeZoneForecast);
     $result = $oDeliveryLimitationManager->getAdLifetimeZoneImpressionsRemaining($oStartDate, $oEndDate, $aCumulativeZoneForecast);
     $this->assertEqual($result, 1111110 + 7);
     // Test 4
     $oStartDate = new Date('2006-02-18 22:07:15');
     $oEndDate = new Date('2006-02-20 23:59:59');
     $aCumulativeZoneForecast = array();
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-18 21:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 1;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-18 22:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 10;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-18 23:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 100;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-19 00:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 1000;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-19 01:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 10000;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-19 02:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 100000;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-19 03:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 1000000;
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-19 04:00:01'));
     $aCumulativeZoneForecast[$operationIntervalID] = 10000000;
     $aCumulativeZoneForecast = $this->_fillForecastArray($aCumulativeZoneForecast);
     $result = $oDeliveryLimitationManager->getAdLifetimeZoneImpressionsRemaining($oStartDate, $oEndDate, $aCumulativeZoneForecast);
     $this->assertEqual($result, 110 + 11111000 + 19 + 24);
     // Test 5
     $oStartDate = new Date('2006-02-07 12:07:15');
     $oEndDate = new Date('2006-02-07 23:59:59');
     $aDeliveryLimitations = array(array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '!~', 'data' => '23', 'executionorder' => 0));
     $oDeliveryLimitationManager = new OA_Maintenance_Priority_DeliveryLimitation($aDeliveryLimitations);
     $oDeliveryLimitationManager->getActiveAdOperationIntervals(12, $oStartDate, $oEndDate);
     $aCumulativeZoneForecast = array();
     $aCumulativeZoneForecast = $this->_fillForecastArray($aCumulativeZoneForecast);
     $result = $oDeliveryLimitationManager->getAdLifetimeZoneImpressionsRemaining($oStartDate, $oEndDate, $aCumulativeZoneForecast);
     $this->assertEqual($result, 11);
     // Test 6
     $oStartDate = new Date('2006-02-07 12:07:15');
     $oEndDate = new Date('2006-02-08 23:59:59');
     $aDeliveryLimitations = array(array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '=~', 'data' => '22', 'executionorder' => 0));
     $oDeliveryLimitationManager = new OA_Maintenance_Priority_DeliveryLimitation($aDeliveryLimitations);
     $oDeliveryLimitationManager->getActiveAdOperationIntervals(12, $oStartDate, $oEndDate);
     $aCumulativeZoneForecast = array();
     $aCumulativeZoneForecast = $this->_fillForecastArray($aCumulativeZoneForecast);
     $result = $oDeliveryLimitationManager->getAdLifetimeZoneImpressionsRemaining($oStartDate, $oEndDate, $aCumulativeZoneForecast);
     $this->assertEqual($result, 2);
     TestEnv::restoreConfig();
 }
 /**
  * A method to test the _getAdImpressions() method.
  *
  * Test 1: Test with invalid parameters, and ensure that zero impressions are
  *         allocated.
  * Test 2: Test with an advertisement that is currently blocked, and ensure
  *         that zero impressions are allocated.
  * Test 3: Test with an advertisement that is not currently blocked, but with
  *         no impressions in the cumulative zone forecast, and ensure that
  *         zero impressions are allocated.
  * Test 4: Test with a simple, single operation interval cumulative zone forecast,
  *         and a blocking delivery limitation, and ensure that the correct number
  *         of impressions are allocated.
  * Test 5: Test with a simple, even operation interval cumulative zone forecast,
  *         and a blocking delivery limitation, and ensure that the correct number
  *         of impressions are allocated.
  * Test 6: Test with an uneven operation interval cumulative zone forecast, and
  *         a blocking delivery limitation, and ensure that the correct number of
  *         impressions are allocated.
  */
 function test_getAdImpressions()
 {
     $aConf =& $GLOBALS['_MAX']['CONF'];
     $aConf['maintenance']['operationInterval'] = 60;
     Mock::generatePartial('OA_Maintenance_Priority_Ad', 'PartialMockOA_Maintenance_Priority_Ad', array('getDeliveryLimitations'));
     Mock::generatePartial('OA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime', 'PartialMockOA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime', array('_getCumulativeZoneForecast'));
     // Test 1
     $oAd = new OA_Maintenance_Priority_Ad(array('ad_id' => 1, 'weight' => 1, 'status' => OA_ENTITY_STATUS_RUNNING, 'type' => 'sql'));
     $totalRequiredAdImpressions = 10;
     $oDate = new Date();
     $oCampaignExpiryDate = new Date();
     $oGetRequiredAdImpressionsLifetime =& $this->_getCurrentTask();
     $oDeliveryLimitaions = new OA_Maintenance_Priority_DeliveryLimitation(null);
     $aAdZones = array();
     $result = $oGetRequiredAdImpressionsLifetime->_getAdImpressions('foo', $totalRequiredAdImpressions, $oDate, $oCampaignExpiryDate, $oDeliveryLimitaions, $aAdZones);
     $this->assertEqual($result, 0);
     $result = $oGetRequiredAdImpressionsLifetime->_getAdImpressions($oAd, 'foo', $oDate, $oCampaignExpiryDate, $oDeliveryLimitaions, $aAdZones);
     $this->assertEqual($result, 0);
     $result = $oGetRequiredAdImpressionsLifetime->_getAdImpressions($oAd, $totalRequiredAdImpressions, 'foo', $oCampaignExpiryDate, $oDeliveryLimitaions, $aAdZones);
     $this->assertEqual($result, 0);
     $result = $oGetRequiredAdImpressionsLifetime->_getAdImpressions($oAd, $totalRequiredAdImpressions, $oDate, 'foo', $oDeliveryLimitaions, $aAdZones);
     $this->assertEqual($result, 0);
     $result = $oGetRequiredAdImpressionsLifetime->_getAdImpressions($oAd, $totalRequiredAdImpressions, $oDate, $oCampaignExpiryDate, 'foo', $aAdZones);
     $this->assertEqual($result, 0);
     $result = $oGetRequiredAdImpressionsLifetime->_getAdImpressions($oAd, $totalRequiredAdImpressions, $oDate, $oCampaignExpiryDate, $oDeliveryLimitaions, 'foo');
     $this->assertEqual($result, 0);
     // Test 2
     $oAd = new PartialMockOA_Maintenance_Priority_Ad($this);
     $aParam = array('ad_id' => 1, 'weight' => 1, 'status' => OA_ENTITY_STATUS_RUNNING, 'type' => 'sql');
     $oAd->setReturnValue('getDeliveryLimitations', array(array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '!~', 'data' => '12', 'executionorder' => 0)));
     $oAd->OA_Maintenance_Priority_Ad($aParam);
     $totalRequiredAdImpressions = 120;
     $oDate = new Date('2006-02-15 12:07:01');
     $oCampaignExpiryDate = new Date('2006-12-15 23:59:59');
     $oGetRequiredAdImpressionsLifetime =& $this->_getCurrentTask();
     $oDeliveryLimitaions = new OA_Maintenance_Priority_DeliveryLimitation($oAd->getDeliveryLimitations());
     $aAdZones = array(array('zone_id' => 1));
     $result = $oGetRequiredAdImpressionsLifetime->_getAdImpressions($oAd, $totalRequiredAdImpressions, $oDate, $oCampaignExpiryDate, $oDeliveryLimitaions, $aAdZones);
     $this->assertEqual($result, 0);
     // Test 3
     $oAd = new PartialMockOA_Maintenance_Priority_Ad($this);
     $aParam = array('ad_id' => 1, 'weight' => 1, 'status' => OA_ENTITY_STATUS_RUNNING, 'type' => 'sql');
     $oAd->setReturnValue('getDeliveryLimitations', array(array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '!~', 'data' => '15', 'executionorder' => 0)));
     $oAd->OA_Maintenance_Priority_Ad($aParam);
     $totalRequiredAdImpressions = 110;
     $oDate = new Date('2006-02-15 12:07:01');
     $oCampaignExpiryDate = new Date('2006-02-15 23:59:59');
     $oGetRequiredAdImpressionsLifetime = new PartialMockOA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime($this);
     $oGetRequiredAdImpressionsLifetime->setReturnValue('_getCumulativeZoneForecast', array());
     $oGetRequiredAdImpressionsLifetime->OA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime();
     $oDeliveryLimitaions = new OA_Maintenance_Priority_DeliveryLimitation($oAd->getDeliveryLimitations());
     $aAdZones = array(array('zone_id' => 1));
     $result = $oGetRequiredAdImpressionsLifetime->_getAdImpressions($oAd, $totalRequiredAdImpressions, $oDate, $oCampaignExpiryDate, $oDeliveryLimitaions, $aAdZones);
     $this->assertEqual($result, 0);
     // Test 4
     $oAd = new PartialMockOA_Maintenance_Priority_Ad($this);
     $aParam = array('ad_id' => 1, 'weight' => 1, 'status' => OA_ENTITY_STATUS_RUNNING, 'type' => 'sql');
     $oAd->setReturnValue('getDeliveryLimitations', array(array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '!~', 'data' => '15', 'executionorder' => 0)));
     $oAd->OA_Maintenance_Priority_Ad($aParam);
     $totalRequiredAdImpressions = 110;
     $oDate = new Date('2006-02-15 12:07:01');
     $oCampaignExpiryDate = new Date('2006-02-15 23:59:59');
     $oGetRequiredAdImpressionsLifetime = new PartialMockOA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime($this);
     $aCumulativeZoneForecast = array();
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 12:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $aCumulativeZoneForecast = $this->_fillForecastArray($aCumulativeZoneForecast);
     $oGetRequiredAdImpressionsLifetime->setReturnValue('_getCumulativeZoneForecast', $aCumulativeZoneForecast);
     $oGetRequiredAdImpressionsLifetime->OA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime();
     $oDeliveryLimitaions = new OA_Maintenance_Priority_DeliveryLimitation($oAd->getDeliveryLimitations());
     $remainingOIs = OX_OperationInterval::getIntervalsRemaining($oDate, $oCampaignExpiryDate);
     $oDeliveryLimitaions->getActiveAdOperationIntervals($remainingOIs, $oDate, $oCampaignExpiryDate);
     $aAdZones = array(array('zone_id' => 1));
     $result = $oGetRequiredAdImpressionsLifetime->_getAdImpressions($oAd, $totalRequiredAdImpressions, $oDate, $oCampaignExpiryDate, $oDeliveryLimitaions, $aAdZones);
     $this->assertEqual($result, 110);
     // Test 5
     $oAd = new PartialMockOA_Maintenance_Priority_Ad($this);
     $aParam = array('ad_id' => 1, 'weight' => 1, 'status' => OA_ENTITY_STATUS_RUNNING, 'type' => 'sql');
     $oAd->setReturnValue('getDeliveryLimitations', array(array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '!~', 'data' => '15', 'executionorder' => 0)));
     $oAd->OA_Maintenance_Priority_Ad($aParam);
     $totalRequiredAdImpressions = 110;
     $oDate = new Date('2006-02-15 12:07:01');
     $oCampaignExpiryDate = new Date('2006-02-15 23:59:59');
     $oGetRequiredAdImpressionsLifetime = new PartialMockOA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime($this);
     $aCumulativeZoneForecast = array();
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 12:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 13:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 14:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 15:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 16:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 17:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 18:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 19:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 20:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 21:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 22:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 23:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $aCumulativeZoneForecast = $this->_fillForecastArray($aCumulativeZoneForecast);
     $oGetRequiredAdImpressionsLifetime->setReturnValue('_getCumulativeZoneForecast', $aCumulativeZoneForecast);
     $oGetRequiredAdImpressionsLifetime->OA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime();
     $oDeliveryLimitaions = new OA_Maintenance_Priority_DeliveryLimitation($oAd->getDeliveryLimitations());
     $remainingOIs = OX_OperationInterval::getIntervalsRemaining($oDate, $oCampaignExpiryDate);
     $oDeliveryLimitaions->getActiveAdOperationIntervals($remainingOIs, $oDate, $oCampaignExpiryDate);
     $aAdZones = array(array('zone_id' => 1));
     $result = $oGetRequiredAdImpressionsLifetime->_getAdImpressions($oAd, $totalRequiredAdImpressions, $oDate, $oCampaignExpiryDate, $oDeliveryLimitaions, $aAdZones);
     $this->assertEqual($result, 10);
     // Test 6
     $oAd = new PartialMockOA_Maintenance_Priority_Ad($this);
     $aParam = array('ad_id' => 1, 'weight' => 1, 'status' => OA_ENTITY_STATUS_RUNNING, 'type' => 'sql');
     $oAd->setReturnValue('getDeliveryLimitations', array(array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '!~', 'data' => '15', 'executionorder' => 0)));
     $oAd->OA_Maintenance_Priority_Ad($aParam);
     $totalRequiredAdImpressions = 110;
     $oDate = new Date('2006-02-15 12:07:01');
     $oCampaignExpiryDate = new Date('2006-02-15 23:59:59');
     $oGetRequiredAdImpressionsLifetime = new PartialMockOA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime($this);
     $aCumulativeZoneForecast = array();
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 12:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 10;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 13:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 20;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 14:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 30;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 15:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 40;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 16:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 17:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 60;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 18:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 50;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 19:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 40;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 20:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 30;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 21:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 20;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 22:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 10;
     $intervalID = OX_OperationInterval::convertDateToOperationIntervalID(new Date('2006-02-15 23:00:01'));
     $aCumulativeZoneForecast[$intervalID] = 10;
     $aCumulativeZoneForecast = $this->_fillForecastArray($aCumulativeZoneForecast);
     $oGetRequiredAdImpressionsLifetime->setReturnValue('_getCumulativeZoneForecast', $aCumulativeZoneForecast);
     $oGetRequiredAdImpressionsLifetime->OA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime();
     $oDeliveryLimitaions = new OA_Maintenance_Priority_DeliveryLimitation($oAd->getDeliveryLimitations());
     $remainingOIs = OX_OperationInterval::getIntervalsRemaining($oDate, $oCampaignExpiryDate);
     $oDeliveryLimitaions->getActiveAdOperationIntervals($remainingOIs, $oDate, $oCampaignExpiryDate);
     $aAdZones = array(array('zone_id' => 1));
     $result = $oGetRequiredAdImpressionsLifetime->_getAdImpressions($oAd, $totalRequiredAdImpressions, $oDate, $oCampaignExpiryDate, $oDeliveryLimitaions, $aAdZones);
     $this->assertEqual($result, 3);
     TestEnv::restoreConfig();
 }