本文整理汇总了PHP中OX_OperationInterval::previousOperationIntervalID方法的典型用法代码示例。如果您正苦于以下问题:PHP OX_OperationInterval::previousOperationIntervalID方法的具体用法?PHP OX_OperationInterval::previousOperationIntervalID怎么用?PHP OX_OperationInterval::previousOperationIntervalID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OX_OperationInterval
的用法示例。
在下文中一共展示了OX_OperationInterval::previousOperationIntervalID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPreviousOperationIntervalID
/**
* A method to test the previousOperationIntervalID() method.
*/
function testPreviousOperationIntervalID()
{
$operationIntervalID = 1;
$operationInterval = 60;
$operationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID, $operationInterval);
$this->assertEqual($operationIntervalID, 0);
$operationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID, $operationInterval);
$this->assertEqual($operationIntervalID, 167);
$operationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID, $operationInterval);
$this->assertEqual($operationIntervalID, 166);
$operationIntervalID = 1;
$operationInterval = 60;
$intervals = 3;
$operationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID, $operationInterval, $intervals);
$this->assertEqual($operationIntervalID, 166);
$operationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID, $operationInterval, $intervals);
$this->assertEqual($operationIntervalID, 163);
$operationIntervalID = 1;
$operationInterval = 30;
$operationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID, $operationInterval);
$this->assertEqual($operationIntervalID, 0);
$operationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID, $operationInterval);
$this->assertEqual($operationIntervalID, 335);
$operationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID, $operationInterval);
$this->assertEqual($operationIntervalID, 334);
$operationIntervalID = 1;
$operationInterval = 30;
$intervals = 3;
$operationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID, $operationInterval, $intervals);
$this->assertEqual($operationIntervalID, 334);
$operationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID, $operationInterval, $intervals);
$this->assertEqual($operationIntervalID, 331);
}
示例2: _calculateZoneImpressionForecastValues
/**
* A private method that calcualtes the ZIF value(s) for a given zone.
*
* For each operation interval that requires the zone's ZIF value to be updated,
* the ZIF value for the zone is calculated via the following algorithm:
*
* - If the zone has been operational for at least ZONE_FORECAST_BASELINE_WEEKS weeks
* (i.e. the zone has actual impressions for the past ZONE_FORECAST_BASELINE_WEEKS
* occurrences of the same operation interval as is currently being updated), then
* the expected impressions value is the average of the past two operation intervals'
* actual impressions of the zone, multiplied by a moving average trend value.
* - Else, if the zone has not been operational for at least
* ZONE_FORECAST_BASELINE_WEEKS weeks, then the expected impressions is set to the
* actual number of impressions in the previous operation interval for that zone.
* - Else the previous operation interval for that zone does not have an actual
* number of impressions, then the expected number of impressions for that
* zone is set to ZONE_FORECAST_DEFAULT_ZONE_IMPRESSIONS.
*
* Note also:
* - If the zone ID exists in the $this->aNewZoneIDs array, then all operation
* intervals for the past week will be updated, not just those in $aRanges.
*
* @access private
* @param integer $zoneId The ID of the zone which may require its ZIF value(s)
* to be calculated.
* @param array $aRanges An array of arrays, containing ranges of operation
* intervals that the zone will need its ZIF values
* updated for.
* @param boolean $newZone The zone is considered to be "new"; store this
* information along with the forecasts.
*
* @return void
*/
function _calculateZoneImpressionForecastValues($zoneId, $aRanges, $newZone)
{
// Check the parameters
if (!is_integer($zoneId) || $zoneId < 0) {
return;
}
if (!is_array($aRanges) || empty($aRanges)) {
return;
}
// Update the ZIF for all ranges
foreach ($aRanges as $aRange) {
// Get the two dates representing operation interval start
// dates for the two operation interval IDs at the lower and
// upper bounds of the range
$tmp = array_keys($aRange);
$min = min($tmp);
$max = max($tmp);
$oRangeLowerDate = new Date();
$oRangeLowerDate->copy($aRange[$min]['start']);
$oRangeUpperDate = new Date();
$oRangeUpperDate->copy($aRange[$max]['start']);
// Get the average impressions delivered by the zone in previous
// operation intervals, for the required operation interval range
$aZoneImpressionAverages = $this->_getZoneImpressionAverages($zoneId, $oRangeLowerDate, $oRangeUpperDate);
// Get the details of all forecast and actual impressions of the
// zone for the required operation interval range, offset by the
// required time interval, so that current trends in differences
// between forecast and actual delivery can be calculated
$oTrendLowerDate = $this->_getTrendLowerDate($oRangeLowerDate);
$oTrendUpperDate = $this->_getTrendUpperDate($oRangeUpperDate);
$aZoneForecastAndImpressionHistory = $this->oDal->getZonePastForecastAndImpressionHistory($zoneId, $oTrendLowerDate, $oTrendUpperDate);
foreach ($aRange as $intervalId => $aInterval) {
if (!isset($aZoneImpressionAverages[$intervalId])) {
// This zone does not have a past average actual impressions delivered
// value for this operation interval ID, and so cannot have been running
// for longer than ZONE_FORECAST_BASELINE_WEEKS - as a result, either
// forecast the value based on the past operation interval's data, or
// use the default value
$previousIntervalID = OX_OperationInterval::previousOperationIntervalID($intervalId);
if (isset($aZoneForecastAndImpressionHistory[$previousIntervalID]['actual_impressions']) && $aZoneForecastAndImpressionHistory[$previousIntervalID]['actual_impressions'] > 0) {
// Use the previous operation interval's actual impressions value as the
// new forecast
OA::debug(" - Forecasting for OI {$intervalId} (starting '" . $aInterval['start']->format('%Y-%m-%d %H:%M:%S') . ' ' . $aInterval['start']->tz->getShortName() . "') based on previous OI value", PEAR_LOG_DEBUG);
$this->_storeForecast($this->aForecastResults, $aZoneForecastAndImpressionHistory, $zoneId, $intervalId, $aInterval, $aZoneForecastAndImpressionHistory[$previousIntervalID]['actual_impressions'], $newZone);
} else {
// Use the default value as the new forecast, and note that the forecast
// is so based
OA::debug(" - Forecasting for OI {$intervalId} (starting '" . $aInterval['start']->format('%Y-%m-%d %H:%M:%S') . ' ' . $aInterval['start']->tz->getShortName() . "') based on default value", PEAR_LOG_DEBUG);
$this->_storeForecast($this->aForecastResults, $aZoneForecastAndImpressionHistory, $zoneId, $intervalId, $aInterval, $this->ZONE_FORECAST_DEFAULT_ZONE_IMPRESSIONS, $newZone, true);
}
} else {
// Get the lower bound operation interval ID of the trend calculation
// range required for this operation interval ID
$offetOperationId = OX_OperationInterval::previousOperationIntervalID($intervalId, null, $this->_getTrendOperationIntervalStartOffset());
// Set the initial forecast and actual impressions values
$forecastImpressions = 0;
$actualImpressions = 0;
// Loop over the trend adjustment range data appropriate to this operation
// interval ID, and sum up the forecast and actual impression values
for ($i = 0; $i < ZONE_FORECAST_TREND_OPERATION_INTERVALS; $i++) {
if (!isset($aZoneForecastAndImpressionHistory[$offetOperationId])) {
// The forecast/impression history of this zone is incomplete, so the
// trend adjustment information cannot be calculated
$forecastImpressions = false;
$actualImpressions = false;
break;
}
//.........这里部分代码省略.........
示例3: getPreviousWeekZoneForcastImpressions
/**
* A method to return the forecast impressions for a zone, indexed by operation interval,
* from the current operation interval through the past week. If no forecast stored in
* the database for a given OI, uses average of forecasts found.
*
* @param integer $zoneId The Zone ID.
* @return mixed An array on success, false on failure. The array is of the format:
* array(
* [operation_interval_id] => array(
* ['zone_id'] => zone_id,
* ['_impressions'] => forecast_impressions,
* ['operation_interval_id'] => operation_interval_id
* )
* [operation_interval_id] => array(
* ['zone_id'] => zone_id,
* ['forecast_impressions'] => forecast_impressions,
* ['operation_interval_id'] => operation_interval_id
* )
* .
* .
* .
* )
*/
function getPreviousWeekZoneForcastImpressions($zoneId)
{
if (empty($zoneId) || !is_numeric($zoneId)) {
OA::debug('Invalid zone ID argument', PEAR_LOG_ERR);
return false;
}
$aConf = $GLOBALS['_MAX']['CONF'];
$oServiceLocator =& OA_ServiceLocator::instance();
$oDate =& $oServiceLocator->get('now');
if (!$oDate) {
return false;
}
// Get previous OI
$oPreviousOI = new Date($oDate);
$oPreviousOI->subtractSeconds(OX_OperationInterval::getOperationInterval() * 60);
// Get the start and end ranges of the current week, up to the previous OI
$aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oPreviousOI);
$oDateWeekStart = new Date();
$oDateWeekStart->copy($aDates['end']);
$oDateWeekStart->subtractSeconds(SECONDS_PER_WEEK - 1);
$oDateWeekEnd = new Date();
$oDateWeekEnd->copy($aDates['end']);
// Select the zone forecasts from the database
$tableName = $this->_getTablename('data_intermediate_ad');
$oneHourInterval = OA_Dal::quoteInterval(1, 'hour');
$query = "\n SELECT\n SUM(impressions) AS forecast_impressions,\n operation_interval_id AS operation_interval_id,\n interval_start AS interval_start,\n interval_end AS interval_end\n FROM\n {$tableName}\n WHERE\n zone_id = {$zoneId}\n AND operation_interval = {$aConf['maintenance']['operationInterval']}\n AND interval_start >= '" . $oDateWeekStart->format('%Y-%m-%d %H:%M:%S') . "'\n AND interval_end <= '" . $oDateWeekEnd->format('%Y-%m-%d %H:%M:%S') . "'\n AND date_time > DATE_SUB('" . $oDateWeekStart->format('%Y-%m-%d %H:%M:%S') . "', {$oneHourInterval})\n AND date_time < DATE_ADD('" . $oDateWeekEnd->format('%Y-%m-%d %H:%M:%S') . "', {$oneHourInterval})\n AND zone_id != 0\n GROUP BY\n \tinterval_start,\n \tinterval_end,\n \toperation_interval_id\n ORDER BY\n interval_start";
$rc = $this->oDbh->query($query);
$totalForecastImpressions = 0;
$count = 0;
if (!PEAR::isError($rc)) {
// Sort the results into an array indexed by the operation interval ID
$aFinalResult = array();
while ($aRow = $rc->fetchRow()) {
$aFinalResult[$aRow['operation_interval_id']] = array('zone_id' => $zoneId, 'forecast_impressions' => $aRow['forecast_impressions'], 'operation_interval_id' => $aRow['operation_interval_id']);
$count++;
$totalForecastImpressions += $aRow['forecast_impressions'];
}
}
$averageForecastImpressions = 0;
if ($count > 0) {
$averageForecastImpressions = floor($totalForecastImpressions / $count);
}
if ($averageForecastImpressions == 0) {
$averageForecastImpressions = $this->getZoneForecastDefaultZoneImpressions();
}
// Check each operation interval ID has a forecast impression value,
// and if not, set to the system default.
for ($operationIntervalID = 0; $operationIntervalID < OX_OperationInterval::operationIntervalsPerWeek(); $operationIntervalID++) {
if (!isset($aFinalResult[$operationIntervalID])) {
$aFinalResult[$operationIntervalID] = array('zone_id' => $zoneId, 'forecast_impressions' => $averageForecastImpressions, 'operation_interval_id' => $operationIntervalID);
}
}
// Overwrite current OI with previous OI to match the zone forecasting algorithm
$currOI = OX_OperationInterval::convertDateToOperationIntervalID($oDate);
$prevOI = OX_OperationInterval::previousOperationIntervalID($currOI);
$aFinalResult[$currOI]['forecast_impressions'] = $aFinalResult[$prevOI]['forecast_impressions'];
// Return data
return $aFinalResult;
}
示例4: array
/**
* A method to get the most recent details of advertisement delivery for
* a given list of advertisement/zone pairs set to deliver in the current
* operation interval. Normally, the data will be retrieved from the previous
* operation interval, but if no data exists for that ad/zone pair, then the
* next previous operation interval will be tried, and so on, up to a limit
* of MAX_PREVIOUS_AD_DELIVERY_INFO_LIMIT minutes. (The default is one week.)
*
* Requires that a current day/time (as a Date object) be registered
* with the OA_ServiceLocator (as "now").
*
* Note: The logic of this method seems a little convoluted, and it is.
* However, it needs to be. The reason being:
* - If an ad delivered in the previous operation interval, it should
* have a priority set in ad_zone_assoc. This should be the most
* recent entry in data_summary_ad_zone_assoc. So, the first step is
* to get the data for all ads that have delivered in the previous
* OI, and the associated prioritisation data.
* - If an ad did not deliver, the prioritisation data set in the
* previous OI is still needed, so the second step is to get those
* ads that had prioiritisation data set in the previous OI, but did
* not deliver.
* - Finally, as some ads are limited by hour (for example), we want to
* to be able to get past prioritisation data for ads that were
* disabled in the last OI, so, we need to look for ad/zone pairs
* that have not yet been found, and get BOTH the prioritisation and
* delivery data from the last OI when the ads were active in the
* zones.
* This is why the method uses a complex, 3 step process!
*
* @access public
* @param array $aCurrentZones An array of Zones, indexed by Zone ID, with each
* Zone containing the Advert objects that are linked
* to deliver in the zone, in the current operation
* interval.
* @return mixed An array of arrays of arrays, each one representing a set of
* ad/zone delivery information, indexed by ad ID and zone ID.
* Each sub-sub array, if present, has the format:
* array (
* 'ad_id' => integer
* 'zone_id' => integer
* 'required_impressions' => integer
* 'requested_impressions' => integer
* 'priority_factor' => double
* 'past_zone_traffic_fraction' => double
* 'impressions' => integer
* )
* Returns false when the current date/time is not set in the
* OA_ServiceLocator.
*/
function &getPreviousAdDeliveryInfo($aCurrentZones)
{
OA::debug(" - Getting details of previous ad/zone delivery", PEAR_LOG_DEBUG);
$aConf = $GLOBALS['_MAX']['CONF'];
$oServiceLocator =& OA_ServiceLocator::instance();
$oDate =& $oServiceLocator->get('now');
if (!$oDate) {
return false;
}
$aAds = array();
$aZones = array();
$aZonesAds = array();
$aPastDeliveryResult = array();
$aPastPriorityResult = array();
$aNonDeliveringPastPriorityResult = array();
$aFinalResult = array();
// Obtain the earliest existing interval_start date found in the
// data_summary_ad_zone_assoc table
$table = $this->_getTablename('data_summary_ad_zone_assoc');
$query = "\n SELECT\n interval_start AS interval_start\n FROM\n {$table}\n ORDER BY\n interval_start\n LIMIT\n 1";
$rc = $this->oDbh->query($query);
if (!PEAR::isError($rc) && $rc->numRows() == 1) {
$aRow = $rc->fetchRow();
$oEarliestPastPriorityRecordDate = new Date($aRow['interval_start']);
// Create a new date that is the limit number of minutes ago
$oLimitDate = new Date();
$oLimitDate->copy($oDate);
$oLimitDate->subtractSeconds(MAX_PREVIOUS_AD_DELIVERY_INFO_LIMIT * 60);
// Is the earliest date before this date?
if ($oEarliestPastPriorityRecordDate->before($oLimitDate)) {
// Use the limit date instead
$oEarliestPastPriorityRecordDate = new Date();
$oEarliestPastPriorityRecordDate->copy($oLimitDate);
}
}
// Obtain the operation interval ID, and the start and end dates of the previous
// operation interval
$currentOperationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID($oDate);
$previousOperationIntervalID = OX_OperationInterval::previousOperationIntervalID($currentOperationIntervalID);
$aDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($oDate);
// Obtain the ad ID, zone ID and number of impressions delivered for every ad/zone
// combination that delivered impressions in the previous operation interval
OA::debug(" - Getting details of ad/zone pairs that delivered last OI", PEAR_LOG_DEBUG);
$table = $this->_getTablename('data_intermediate_ad');
$query = "\n SELECT\n ad_id AS ad_id,\n zone_id AS zone_id,\n SUM(impressions) AS impressions\n FROM\n {$table}\n WHERE\n operation_interval = {$aConf['maintenance']['operationInterval']}\n AND operation_interval_id = {$previousOperationIntervalID}\n AND interval_start = '" . $aDates['start']->format('%Y-%m-%d %H:%M:%S') . "'\n AND interval_end = '" . $aDates['end']->format('%Y-%m-%d %H:%M:%S') . "'\n AND ad_id != 0\n AND zone_id != 0\n GROUP BY\n ad_id,\n zone_id\n ORDER BY\n ad_id,\n zone_id";
$rc = $this->oDbh->query($query);
while ($aRow = $rc->fetchRow()) {
// Store the ad ID as being one that has delivered
$aAds[$aRow['ad_id']] = $aRow['ad_id'];
// Store the zone ID as one that had impressions in it
//.........这里部分代码省略.........
示例5: testGetPreviousAdDeliveryInfo
//.........这里部分代码省略.........
$conf = $GLOBALS['_MAX']['CONF'];
$oDbh =& OA_DB::singleton();
$oMaxDalMaintenance = new OA_Dal_Maintenance_Priority();
$aEmptyZoneAdArray = array();
$aAdParams = array('ad_id' => 1, 'active' => 't', 'type' => 'sql', 'weight' => 1);
$oAd = new OA_Maintenance_Priority_Ad($aAdParams);
$oZone = new OX_Maintenance_Priority_Zone(array('zoneid' => 1));
$oZone->addAdvert($oAd);
$aZoneAdArray = array($oZone->id => $oZone);
// Test 1
$oServiceLocator =& OA_ServiceLocator::instance();
$oServiceLocator->remove('now');
$result =& $oMaxDalMaintenance->getPreviousAdDeliveryInfo($aEmptyZoneAdArray);
$this->assertFalse($result);
// Test 2
$oDate = new Date();
$oServiceLocator->register('now', $oDate);
$result =& $oMaxDalMaintenance->getPreviousAdDeliveryInfo($aEmptyZoneAdArray);
$this->assertEqual(count($result), 0);
// Test 3
$operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID($oDate);
$aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oDate);
$oNow = new Date();
$bannerId1 = $this->_insertCampaignBanner();
$aData = array($conf['maintenance']['operationInterval'], $operationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId1, 0, 1, 1, $oNow->format('%Y-%m-%d %H:%M:%S'));
$idDia = $this->_insertDataIntermediateAd($aData);
$result =& $oMaxDalMaintenance->getPreviousAdDeliveryInfo($aEmptyZoneAdArray);
$this->assertEqual(count($result), 0);
$oDate =& $oServiceLocator->get('now');
DataGenerator::cleanUp();
$oServiceLocator->register('now', $oDate);
// Test 4
$operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID($oDate);
$previousOperationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID);
$aDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($oDate);
$bannerId1 = $this->_insertCampaignBanner();
$aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId1, 0, 1, 1, $oNow->format('%Y-%m-%d %H:%M:%S'));
$idDia = $this->_insertDataIntermediateAd($aData);
$result =& $oMaxDalMaintenance->getPreviousAdDeliveryInfo($aEmptyZoneAdArray);
$this->assertEqual(count($result), 1);
$this->assertEqual($result[1][1]['ad_id'], $bannerId1);
$this->assertEqual($result[1][1]['zone_id'], 1);
$this->assertNull($result[1][1]['required_impressions']);
$this->assertNull($result[1][1]['requested_impressions']);
$this->assertNull($result[1][1]['priority_factor']);
$this->assertNull($result[1][1]['past_zone_traffic_fraction']);
$this->assertEqual($result[1][1]['impressions'], 1);
$oDate =& $oServiceLocator->get('now');
DataGenerator::cleanUp();
$oServiceLocator->register('now', $oDate);
// Test 5, 5a
$operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID($oDate);
$previousOperationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID);
$previousOperationIntervalID = OX_OperationInterval::previousOperationIntervalID($previousOperationIntervalID);
$aDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($oDate);
$aDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($aDates['start']);
$bannerId1 = $this->_insertCampaignBanner();
$aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId1, 0, 1, 1, $oNow->format('%Y-%m-%d %H:%M:%S'));
$idDia = $this->_insertDataIntermediateAd($aData);
$result =& $oMaxDalMaintenance->getPreviousAdDeliveryInfo($aEmptyZoneAdArray);
$this->assertEqual(count($result), 0);
$result =& $oMaxDalMaintenance->getPreviousAdDeliveryInfo($aZoneAdArray);
$this->assertEqual(count($result), 0);
$oDate =& $oServiceLocator->get('now');
DataGenerator::cleanUp();
$oServiceLocator->register('now', $oDate);
示例6: testGetAdLifetimeZoneImpressionsRemaining
/**
* 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);
//.........这里部分代码省略.........