本文整理汇总了PHP中TestEnv::installPluginPackage方法的典型用法代码示例。如果您正苦于以下问题:PHP TestEnv::installPluginPackage方法的具体用法?PHP TestEnv::installPluginPackage怎么用?PHP TestEnv::installPluginPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestEnv
的用法示例。
在下文中一共展示了TestEnv::installPluginPackage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* This setUp method is being used to install a package which contains (at the moment only one)
* test (Dummy) plugins which are then used by the test scripts to test the extension point integrations.
*
*/
function setUp()
{
$oPkgMgr = new OX_PluginManager();
//install the package of test (dummy) plugins for testing the extension points
unset($GLOBALS['_MAX']['CONF']['plugins']['openXTests']);
unset($GLOBALS['_MAX']['CONF']['pluginGroupComponents']['Dummy']);
TestEnv::installPluginPackage('openXTests');
}
示例2: Test_OA_Maintenance_Priority_DeliveryLimitation
/**
* The constructor method.
*/
function Test_OA_Maintenance_Priority_DeliveryLimitation()
{
$this->UnitTestCase();
Mock::generatePartial('OA_Maintenance_Priority_DeliveryLimitation', 'Partial_MockOA_Maintenance_Priority_DeliveryLimitation', array('_getOperationInterval'));
// Install the openXDeliveryLog plugin
TestEnv::uninstallPluginPackage('openXDeliveryLimitations', false);
TestEnv::installPluginPackage('openXDeliveryLimitations', false);
OA_setTimeZoneUTC();
}
示例3: setUp
/**
* This setUp method is being used to install a package which contains (at the moment only one)
* test (Dummy) plugins which are then used by the test scripts to test the extension point integrations.
*
*/
function setUp()
{
//install the package of test (dummy) plugins for testing the extension points
unset($GLOBALS['_MAX']['CONF']['plugins']['openXTests']);
unset($GLOBALS['_MAX']['CONF']['pluginGroupComponents']['Dummy']);
TestEnv::installPluginPackage('openXTests');
MAX_commonInitVariables();
$this->tmpCookie = $_COOKIE;
$_COOKIE = array();
}
示例4: Test_OA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime
/**
* The constructor method.
*/
function Test_OA_Maintenance_Priority_AdServer_Task_GetRequiredAdImpressionsLifetime()
{
$this->UnitTestCase();
Mock::generate('MAX_Dal_Entities');
Mock::generate('OA_Dal_Maintenance_Priority');
Mock::generate('OA_DB_Table_Priority');
// Install the openXDeliveryLog plugin
TestEnv::uninstallPluginPackage('openXDeliveryLimitations', false);
TestEnv::installPluginPackage('openXDeliveryLimitations', false);
}
示例5: testNoData
/**
* A method to test when there are no old format raw requests,
* impressions and clicks.
*/
function testNoData()
{
$aConf =& $GLOBALS['_MAX']['CONF'];
$aConf['maintenance']['operationInterval'] = 60;
// Prepare an array of the required tables used in testing
$aTables = array($aConf['table']['prefix'] . $aConf['table']['data_raw_ad_request'] => $aConf['table']['prefix'] . 'data_bkt_r', $aConf['table']['prefix'] . $aConf['table']['data_raw_ad_impression'] => $aConf['table']['prefix'] . 'data_bkt_m', $aConf['table']['prefix'] . $aConf['table']['data_raw_ad_click'] => $aConf['table']['prefix'] . 'data_bkt_c');
// Install the openXDeliveryLog plugin, which will create the
// data bucket tables required for testing
TestEnv::installPluginPackage('openXDeliveryLog', false);
// Ensure that there are no old format raw data
foreach ($aTables as $rawTable => $bucketTable) {
$query = "\n SELECT\n COUNT(*) AS count\n FROM\n " . $this->oDbh->quoteIdentifier($rawTable, true);
$rsResult = $this->oDbh->query($query);
$this->assertNotA($rsReults, 'PEAR_Error');
$rows = $rsResult->numRows();
$this->assertEqual($rows, 1);
$aRow = $rsResult->fetchRow();
$this->assertEqual($aRow['count'], 0);
}
// Ensure that there are no new format bucket data
foreach ($aTables as $rawTable => $bucketTable) {
$query = "\n SELECT\n COUNT(*) AS count\n FROM\n " . $this->oDbh->quoteIdentifier($bucketTable, true);
$rsResult = $this->oDbh->query($query);
$this->assertNotA($rsReults, 'PEAR_Error');
$rows = $rsResult->numRows();
$this->assertEqual($rows, 1);
$aRow = $rsResult->fetchRow();
$this->assertEqual($aRow['count'], 0);
}
// Run the migration of raw data DAL code for a given OI
$oStart = new Date('2009-01-09 12:00:00');
$oEnd = new Date('2009-01-09 12:59:59');
$this->oDal->migrateRawRequests($oStart, $oEnd);
$this->oDal->migrateRawImpressions($oStart, $oEnd);
$this->oDal->migrateRawClicks($oStart, $oEnd);
// Re-test that there are still no new format bucket data
foreach ($aTables as $rawTable => $bucketTable) {
$query = "\n SELECT\n COUNT(*) AS count\n FROM\n " . $this->oDbh->quoteIdentifier($bucketTable, true);
$rsResult = $this->oDbh->query($query);
$this->assertNotA($rsReults, 'PEAR_Error');
$rows = $rsResult->numRows();
$this->assertEqual($rows, 1);
$aRow = $rsResult->fetchRow();
$this->assertEqual($aRow['count'], 0);
}
// Uninstall the installed plugin
TestEnv::uninstallPluginPackage('openXDeliveryLog', false);
// Restore the test environment configuration
TestEnv::restoreConfig();
}
示例6: test_MAX_Delivery_log_logVariableValues
/**
* A method to test the MAX_Delivery_log_logVariableValues() function.
*/
function test_MAX_Delivery_log_logVariableValues()
{
$aConf =& $GLOBALS['_MAX']['CONF'];
$aConf['maintenance']['operationInterval'] = 60;
$GLOBALS['_MAX']['NOW'] = time();
$oNowDate = new Date($GLOBALS['_MAX']['NOW']);
// Test to ensure that the openXDeliveryLog plugin's data bucket
// table does not exist
$oTable = new OA_DB_Table();
$tableExists = $oTable->extistsTable($aConf['table']['prefix'] . 'data_bkt_a_var');
$this->assertFalse($tableExists);
// Test calling the main logging function without any plugins installed,
// to ensure that this does not result in any kind of error
$aVariables = array(55 => array('variable_id' => 55, 'tracker_id' => 1, 'name' => 'fooVar', 'type' => 'string', 'variablecode' => ''), 66 => array('variable_id' => 66, 'tracker_id' => 1, 'name' => 'barVar', 'type' => 'string', 'variablecode' => ''));
$_GET['fooVar'] = 'foo';
$_GET['barVar'] = 'bar';
MAX_Delivery_log_logVariableValues($aVariables, 1, 1, 'singleDB');
// Install the openXDeliveryLog plugin
TestEnv::installPluginPackage('openXDeliveryLog', false);
// Test to ensure that the openXDeliveryLog plugin's data bucket
// table now does exist
$tableExists = $oTable->extistsTable($aConf['table']['prefix'] . 'data_bkt_a_var');
$this->assertTrue($tableExists);
// Ensure that there are is nothing logged in the data bucket table
$doData_bkt_a_var = OA_Dal::factoryDO('data_bkt_a_var');
$doData_bkt_a_var->find();
$rows = $doData_bkt_a_var->getRowCount();
$this->assertEqual($rows, 0);
// Call the variable value logging function
MAX_Delivery_log_logVariableValues($aVariables, 1, 1, 'singleDB');
// Ensure that the data was logged correctly
$doData_bkt_a_var = OA_Dal::factoryDO('data_bkt_a_var');
$doData_bkt_a_var->find();
$rows = $doData_bkt_a_var->getRowCount();
$this->assertEqual($rows, 2);
$doData_bkt_a_var = OA_Dal::factoryDO('data_bkt_a_var');
$doData_bkt_a_var->server_conv_id = 1;
$doData_bkt_a_var->server_raw_ip = 'singleDB';
$doData_bkt_a_var->tracker_variable_id = 55;
$doData_bkt_a_var->find();
$rows = $doData_bkt_a_var->getRowCount();
$this->assertEqual($rows, 1);
$doData_bkt_a_var->fetch();
$this->assertEqual($doData_bkt_a_var->value, 'foo');
$this->assertEqual($doData_bkt_a_var->date_time, $oNowDate->format('%Y-%m-%d %H:%M:%S'));
// Uninstall the openXDeliveryLog plugin
TestEnv::uninstallPluginPackage('openXDeliveryLog', false);
// Restore the test configuration file
TestEnv::restoreConfig();
}
示例7: setUp
function setUp()
{
$oPkgMgr = new OX_PluginManager();
TestEnv::uninstallPluginPackage('openXDeliveryCacheStore');
TestEnv::installPluginPackage('openXDeliveryCacheStore');
}
示例8: test_locateComponents
/**
* A method to test the _locateComponents() method.
*/
function test_locateComponents()
{
$aConf = $GLOBALS['_MAX']['CONF'];
// Test 1: There are no deliveryLog group plugins installed, test that
// an empty array is returned
$oSummariseIntermediate = new OX_Maintenance_Statistics_Task_MigrateBucketData();
$aComponents = $oSummariseIntermediate->_locateComponents();
$this->assertTrue(is_array($aComponents));
$this->assertTrue(empty($aComponents));
// Setup the default OpenX delivery logging plugin for the next test
TestEnv::installPluginPackage('openXDeliveryLog', false);
// Test 2: Test with the default OpenX delivery logging plugin installed
$oSummariseIntermediate = new OX_Maintenance_Statistics_Task_MigrateBucketData();
$aComponents = $oSummariseIntermediate->_locateComponents();
$this->assertTrue(is_array($aComponents));
$this->assertEqual(count($aComponents), 3);
$dia = $aConf['table']['prefix'] . 'data_intermediate_ad';
$this->assertTrue(is_array($aComponents[$dia]));
$this->assertEqual(count($aComponents[$dia]), 3);
$aComponentClasses = array();
foreach ($aComponents[$dia] as $oComponent) {
$aComponentClasses[] = get_class($oComponent);
}
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogRequest_LogRequest', $aComponentClasses));
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogImpression_LogImpression', $aComponentClasses));
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogClick_LogClick', $aComponentClasses));
$diac = $aConf['table']['prefix'] . 'data_intermediate_ad_connection';
$this->assertTrue(is_array($aComponents[$diac]));
$this->assertEqual(count($aComponents[$diac]), 1);
$aComponentClasses = array();
foreach ($aComponents[$diac] as $oComponent) {
$aComponentClasses[] = get_class($oComponent);
}
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogConversion_LogConversion', $aComponentClasses));
$diavv = $aConf['table']['prefix'] . 'data_intermediate_ad_variable_value';
$this->assertTrue(is_array($aComponents[$diavv]));
$this->assertEqual(count($aComponents[$diavv]), 1);
$aComponentClasses = array();
foreach ($aComponents[$diavv] as $oComponent) {
$aComponentClasses[] = get_class($oComponent);
}
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogConversion_LogConversionVariable', $aComponentClasses));
/*
TODO: move this test from core code to the plugin. only bundled plugins (or the test plugin) can be used in core tests
// Setup the default OpenX country based impression and click delivery logging plugin for the next test
TestEnv::installPluginPackage('openXDeliveryLogCountry', false);
// Test 3: Test with the default OpenX delivery logging plugin and the OpenX country based impression
// and click delivery logging plugin installed
$aComponents = $oSummariseIntermediate->_locateComponents();
$this->assertTrue(is_array($aComponents));
$this->assertEqual(count($aComponents), 4);
$dia = $aConf['table']['prefix'] . 'data_intermediate_ad';
$this->assertTrue(is_array($aComponents[$dia]));
$this->assertEqual(count($aComponents[$dia]), 4);
$aComponentClasses = array();
foreach ($aComponents[$dia] as $oComponent) {
$aComponentClasses[] = get_class($oComponent);
}
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogRequest_LogRequest', $aComponentClasses));
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogImpression_LogImpression', $aComponentClasses));
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogClick_LogClick', $aComponentClasses));
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogImpression_logImpressionBackup', $aComponentClasses));
$diac = $aConf['table']['prefix'] . 'data_intermediate_ad_connection';
$this->assertTrue(is_array($aComponents[$diac]));
$this->assertEqual(count($aComponents[$diac]), 1);
$aComponentClasses = array();
foreach ($aComponents[$diac] as $oComponent) {
$aComponentClasses[] = get_class($oComponent);
}
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogConversion_LogConversion', $aComponentClasses));
$diavv = $aConf['table']['prefix'] . 'data_intermediate_ad_variable_value';
$this->assertTrue(is_array($aComponents[$diavv]));
$this->assertEqual(count($aComponents[$diavv]), 1);
$aComponentClasses = array();
foreach ($aComponents[$diavv] as $oComponent) {
$aComponentClasses[] = get_class($oComponent);
}
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogConversion_LogConversionVariable', $aComponentClasses));
$sc = $aConf['table']['prefix'] . 'stats_country';
$this->assertTrue(is_array($aComponents[$sc]));
$this->assertEqual(count($aComponents[$sc]), 2);
$aComponentClasses = array();
foreach ($aComponents[$sc] as $oComponent) {
$aComponentClasses[] = get_class($oComponent);
}
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogCountry_LogImpressionCountry', $aComponentClasses));
$this->assertTrue(in_array('Plugins_DeliveryLog_OxLogCountry_LogClickCountry', $aComponentClasses));
// Uninstall the installed plugins
TestEnv::uninstallPluginPackage('openXDeliveryLogCountry', false);
*/
// Uninstall the installed plugins
TestEnv::uninstallPluginPackage('openXDeliveryLog', false);
// Reset the testing environment
TestEnv::restoreEnv();
}
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:98,代码来源:SummariseIntermediate_locateComponents.mts.test.php
示例9: testHourly
/**
* The complete end-to-end integration test for 60 minute operation intervals.
*/
function testHourly()
{
$aConf =& $GLOBALS['_MAX']['CONF'];
$aConf['maintenance']['operationInterval'] = 60;
$aConf['log']['priority'] = 'PEAR_LOG_DEBUG';
// Setup the default OpenX delivery logging plugin for the next test
TestEnv::installPluginPackage('openXDeliveryLog', false);
/**********************************************************************/
// Test to ensure there are no entries in any of the system tables yet
$doUserlog = OA_Dal::factoryDO('userlog');
$doUserlog->find();
$this->assertEqual($doUserlog->getRowCount(), 0);
$doLog_maintenance_statistics = OA_Dal::factoryDO('log_maintenance_statistics');
$doLog_maintenance_statistics->find();
$this->assertEqual($doLog_maintenance_statistics->getRowCount(), 0);
$doData_intermediate_ad_connection = OA_Dal::factoryDO('data_intermediate_ad_connection');
$doData_intermediate_ad_connection->find();
$this->assertEqual($doData_intermediate_ad_connection->getRowCount(), 0);
$doData_intermediate_ad_variable_value = OA_Dal::factoryDO('data_intermediate_ad_variable_value');
$doData_intermediate_ad_variable_value->find();
$this->assertEqual($doData_intermediate_ad_variable_value->getRowCount(), 0);
$doData_intermediate_ad = OA_Dal::factoryDO('data_intermediate_ad');
$doData_intermediate_ad->find();
$this->assertEqual($doData_intermediate_ad->getRowCount(), 0);
$doData_summary_ad_hourly = OA_Dal::factoryDO('data_summary_ad_hourly');
$doData_summary_ad_hourly->find();
$this->assertEqual($doData_summary_ad_hourly->getRowCount(), 0);
$doData_bkt_r = OA_Dal::factoryDO('data_bkt_r');
$doData_bkt_r->find();
$this->assertEqual($doData_bkt_r->getRowCount(), 0);
$doData_bkt_r = OA_Dal::factoryDO('data_bkt_m');
$doData_bkt_r->find();
$this->assertEqual($doData_bkt_r->getRowCount(), 0);
$doData_bkt_r = OA_Dal::factoryDO('data_bkt_c');
$doData_bkt_r->find();
$this->assertEqual($doData_bkt_r->getRowCount(), 0);
$doData_bkt_r = OA_Dal::factoryDO('data_bkt_a');
$doData_bkt_r->find();
$this->assertEqual($doData_bkt_r->getRowCount(), 0);
$doData_bkt_r = OA_Dal::factoryDO('data_bkt_a_var');
$doData_bkt_r->find();
$this->assertEqual($doData_bkt_r->getRowCount(), 0);
/**********************************************************************/
// Prepare the current date/time for testing
$oNowDate = new Date('2008-08-28 15:01:00');
$oServiceLocator =& OA_ServiceLocator::instance();
$oServiceLocator->register('now', $oNowDate);
// Test 1: Run the MSE process with NO DATA
$oMaintenanceStatisitcs = new OX_Maintenance_Statistics();
$oMaintenanceStatisitcs->run();
/**********************************************************************/
// Test to ensure there are STILL no entries in any of the system tables
$doUserlog = OA_Dal::factoryDO('userlog');
$doUserlog->find();
$this->assertEqual($doUserlog->getRowCount(), 0);
$doLog_maintenance_statistics = OA_Dal::factoryDO('log_maintenance_statistics');
$doLog_maintenance_statistics->find();
$this->assertEqual($doLog_maintenance_statistics->getRowCount(), 0);
$doData_intermediate_ad_connection = OA_Dal::factoryDO('data_intermediate_ad_connection');
$doData_intermediate_ad_connection->find();
$this->assertEqual($doData_intermediate_ad_connection->getRowCount(), 0);
$doData_intermediate_ad_variable_value = OA_Dal::factoryDO('data_intermediate_ad_variable_value');
$doData_intermediate_ad_variable_value->find();
$this->assertEqual($doData_intermediate_ad_variable_value->getRowCount(), 0);
$doData_intermediate_ad = OA_Dal::factoryDO('data_intermediate_ad');
$doData_intermediate_ad->find();
$this->assertEqual($doData_intermediate_ad->getRowCount(), 0);
$doData_summary_ad_hourly = OA_Dal::factoryDO('data_summary_ad_hourly');
$doData_summary_ad_hourly->find();
$this->assertEqual($doData_summary_ad_hourly->getRowCount(), 0);
$doData_bkt_r = OA_Dal::factoryDO('data_bkt_r');
$doData_bkt_r->find();
$this->assertEqual($doData_bkt_r->getRowCount(), 0);
$doData_bkt_r = OA_Dal::factoryDO('data_bkt_m');
$doData_bkt_r->find();
$this->assertEqual($doData_bkt_r->getRowCount(), 0);
$doData_bkt_r = OA_Dal::factoryDO('data_bkt_c');
$doData_bkt_r->find();
$this->assertEqual($doData_bkt_r->getRowCount(), 0);
$doData_bkt_r = OA_Dal::factoryDO('data_bkt_a');
$doData_bkt_r->find();
$this->assertEqual($doData_bkt_r->getRowCount(), 0);
$doData_bkt_r = OA_Dal::factoryDO('data_bkt_a_var');
$doData_bkt_r->find();
$this->assertEqual($doData_bkt_r->getRowCount(), 0);
/**********************************************************************/
// Generate some tracker variables:
//
// - Tracker ID 1: Tracks no variables
// - Tracker ID 2: Tracks a standard variable value
// - Tracker ID 3: Tracks a de-duplicating variable value
// - Tracker ID 4: Tracks a reject if empty variable value
// - Tracker ID 5: Tracks a basket variable value and a number of
// items variable value
$doVariables = OA_Dal::factoryDO('variables');
$doVariables->trackerid = 2;
$doVariables->name = 'Normal Variable';
//.........这里部分代码省略.........
示例10: testGenerateTags
function testGenerateTags()
{
if (!$this->zoneId) {
return;
}
TestEnv::uninstallPluginPackage('openXInvocationTags');
TestEnv::installPluginPackage('openXInvocationTags');
$this->expectError();
$this->assertFalse($this->oApi->generateTags(-1, 'foo'));
$this->expectError();
$this->assertFalse($this->oApi->generateTags($this->zoneId, 'foo'));
$tag1 = $this->oApi->generateTags($this->zoneId, 'adjs');
$tag2 = $this->oApi->generateTags($this->zoneId, 'adjs', array('source' => 'x'));
$this->assertTrue($tag1);
$this->assertTrue($tag2);
$this->assertNotEqual($tag1, $tag2);
TestEnv::uninstallPluginPackage('openXInvocationTags');
}
示例11: testRequestImpressionClickFunction
/**
* A method to test the MAX_Delivery_log_logAdRequest(),
* MAX_Delivery_log_logAdImpression() and MAX_Delivery_log_logAdClick()
* functions.
*/
function testRequestImpressionClickFunction()
{
$aConf =& $GLOBALS['_MAX']['CONF'];
$aConf['maintenance']['operationInterval'] = 60;
$GLOBALS['_MAX']['NOW'] = time();
$oNowDate = new Date($GLOBALS['_MAX']['NOW']);
$aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oNowDate);
$intervalStart = $aDates['start']->format('%Y-%m-%d %H:%M:%S');
$aTables = array('MAX_Delivery_log_logAdRequest' => 'data_bkt_r', 'MAX_Delivery_log_logAdImpression' => 'data_bkt_m', 'MAX_Delivery_log_logAdClick' => 'data_bkt_c');
foreach ($aTables as $function => $table) {
// Test to ensure that the openXDeliveryLog plugin's data bucket
// table does not exist
$oTable = new OA_DB_Table();
$tableExists = $oTable->extistsTable($aConf['table']['prefix'] . $table);
$this->assertFalse($tableExists);
// Test calling the main logging function without any plugins installed,
// to ensure that this does not result in any kind of error
unset($GLOBALS['_MAX']['deliveryData']['Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon']);
call_user_func_array($function, array(1, 1));
}
// Install the openXDeliveryLog plugin
TestEnv::installPluginPackage('openXDeliveryLog', false);
foreach ($aTables as $function => $table) {
// Test to ensure that the openXDeliveryLog plugin's data bucket
// table now does exist
$tableExists = $oTable->extistsTable($aConf['table']['prefix'] . $table);
$this->assertTrue($tableExists);
// Ensure that there are is nothing logged in the data bucket table
$doData_bkt = OA_Dal::factoryDO($table);
$doData_bkt->find();
$rows = $doData_bkt->getRowCount();
$this->assertEqual($rows, 0);
// Call the main logging function
unset($GLOBALS['_MAX']['deliveryData']['Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon']);
call_user_func_array($function, array(1, 1));
// Ensure that the data was logged correctly
$doData_bkt = OA_Dal::factoryDO($table);
$doData_bkt->find();
$rows = $doData_bkt->getRowCount();
if ($table == 'data_bkt_r') {
// Request logging is disabled by default. Nothing should have been logged by now
$this->assertEqual($rows, 0);
// Enable it
$GLOBALS['_MAX']['CONF']['logging']['adRequests'] = true;
unset($GLOBALS['_MAX']['deliveryData']['Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon']);
call_user_func_array($function, array(1, 1));
// Now ensure that the data was logged correctly
$doData_bkt->find();
$rows = $doData_bkt->getRowCount();
}
$this->assertEqual($rows, 1);
$doData_bkt = OA_Dal::factoryDO($table);
$doData_bkt->creative_id = 1;
$doData_bkt->zone_id = 1;
$doData_bkt->find();
$rows = $doData_bkt->getRowCount();
$this->assertEqual($rows, 1);
$doData_bkt->fetch();
$this->assertEqual($doData_bkt->count, 1);
$this->assertEqual($doData_bkt->interval_start, $intervalStart);
// Call the main logging function again
unset($GLOBALS['_MAX']['deliveryData']['Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon']);
call_user_func_array($function, array(1, 1));
// Ensure that the data was logged correctly
$doData_bkt = OA_Dal::factoryDO($table);
$doData_bkt->find();
$rows = $doData_bkt->getRowCount();
$this->assertEqual($rows, 1);
$doData_bkt = OA_Dal::factoryDO($table);
$doData_bkt->creative_id = 1;
$doData_bkt->zone_id = 1;
$doData_bkt->find();
$rows = $doData_bkt->getRowCount();
$this->assertEqual($rows, 1);
$doData_bkt->fetch();
$this->assertEqual($doData_bkt->count, 2);
$this->assertEqual($doData_bkt->interval_start, $intervalStart);
// Call the main logging function again, but with a differen
// creative/zone pair
unset($GLOBALS['_MAX']['deliveryData']['Plugin_deliveryDataPrepare_oxDeliveryDataPrepare_dataCommon']);
call_user_func_array($function, array(2, 1));
// Ensure that the data was logged correctly
$doData_bkt = OA_Dal::factoryDO($table);
$doData_bkt->find();
$rows = $doData_bkt->getRowCount();
$this->assertEqual($rows, 2);
$doData_bkt = OA_Dal::factoryDO($table);
$doData_bkt->creative_id = 1;
$doData_bkt->zone_id = 1;
$doData_bkt->find();
$rows = $doData_bkt->getRowCount();
$this->assertEqual($rows, 1);
$doData_bkt->fetch();
$this->assertEqual($doData_bkt->count, 2);
$this->assertEqual($doData_bkt->interval_start, $intervalStart);
//.........这里部分代码省略.........
示例12: testSummariseBucketsAggregate
//.........这里部分代码省略.........
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsAggregate() called with invalid start/end date parameters -- not Date objects.");
$aDates['end'] = $savedValue;
// Test 7: Test with invalid start/end dates
$savedValue = $aDates['start'];
$aDates['start'] = new Date('2008-08-21 08:00:00');
$result = $oDalMaintenanceStatistics->summariseBucketsAggregate($statisticsTableName, $aMigrationMaps, $aDates, $aExtras);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsAggregate() called with invalid start/end date parameters -- not operation interval bounds.");
$aDates['start'] = $savedValue;
$savedValue = $aDates['end'];
$aDates['end'] = new Date('2008-08-22 09:59:59');
$result = $oDalMaintenanceStatistics->summariseBucketsAggregate($statisticsTableName, $aMigrationMaps, $aDates, $aExtras);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsAggregate() called with invalid start/end date parameters -- not operation interval bounds.");
$aDates['end'] = $savedValue;
// Test 8: Test with an invalid statistics table name
$savedValue = $statisticsTableName;
$statisticsTableName = 'foo';
$result = $oDalMaintenanceStatistics->summariseBucketsAggregate($statisticsTableName, $aMigrationMaps, $aDates, $aExtras);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDREQUEST);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsAggregate() called with invalid statistics table 'foo'.");
$statisticsTableName = $savedValue;
// Test 9: Test with no data_bkt_r table in the database
$result = $oDalMaintenanceStatistics->summariseBucketsAggregate($statisticsTableName, $aMigrationMaps, $aDates, $aExtras);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDREQUEST);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsAggregate() called with migration map index '0' having invalid bucket table '{$aConf['table']['prefix']}data_bkt_r'.");
// Install the openXDeliveryLog plugin, which will create the
// data_bkt_r, data_bkt_m and data_bkt_c tables required for testing
TestEnv::installPluginPackage('openXDeliveryLog', false);
// Test 10: Test with all tables present, but no data
$result = $oDalMaintenanceStatistics->summariseBucketsAggregate($statisticsTableName, $aMigrationMaps, $aDates, $aExtras);
$this->assertEqual($result, 0);
// Insert some data into the data_bkt_r, data_bkt_m and
// data_bkt_c tables in the incorrect operation interval
$oData_bkt_r = OA_Dal::factoryDO('data_bkt_r');
$oData_bkt_r->interval_start = '2008-08-21 08:00:00';
$oData_bkt_r->creative_id = 1;
$oData_bkt_r->zone_id = 2;
$oData_bkt_r->count = 10;
DataGenerator::generateOne($oData_bkt_r);
$oData_bkt_m = OA_Dal::factoryDO('data_bkt_m');
$oData_bkt_m->interval_start = '2008-08-21 08:00:00';
$oData_bkt_m->creative_id = 1;
$oData_bkt_m->zone_id = 2;
$oData_bkt_m->count = 9;
DataGenerator::generateOne($oData_bkt_m);
$oData_bkt_c = OA_Dal::factoryDO('data_bkt_c');
$oData_bkt_c->interval_start = '2008-08-21 08:00:00';
$oData_bkt_c->creative_id = 1;
$oData_bkt_c->zone_id = 2;
$oData_bkt_c->count = 1;
DataGenerator::generateOne($oData_bkt_c);
// Test 11: Test with data in the incorrect operation interval
$result = $oDalMaintenanceStatistics->summariseBucketsAggregate($statisticsTableName, $aMigrationMaps, $aDates, $aExtras);
$this->assertEqual($result, 0);
// Insert some data into the data_bkt_r, data_bkt_m and
// data_bkt_c tables in the incorrect operation interval
$oData_bkt_r = OA_Dal::factoryDO('data_bkt_r');
$oData_bkt_r->interval_start = '2008-08-21 09:00:00';
$oData_bkt_r->creative_id = 1;
$oData_bkt_r->zone_id = 2;
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:67,代码来源:Statistics_summariseBucketsAggregate.dal.test.php
示例13: testSummariseBucketsRaw
/**
* A method to test the summariseBucketsRaw() method.
*/
function testSummariseBucketsRaw()
{
$aConf =& $GLOBALS['_MAX']['CONF'];
$aConf['maintenance']['operationInterval'] = 60;
// Prepare standard test parameters
$statisticsTableName = $aConf['table']['prefix'] . 'data_intermediate_ad_connection';
$aMigrationDetails = array('method' => 'raw', 'bucketTable' => $aConf['table']['prefix'] . 'data_bkt_a', 'dateTimeColumn' => 'date_time', 'source' => array(0 => 'server_conv_id', 1 => 'server_ip', 2 => 'tracker_id', 3 => 'date_time', 4 => 'action_date_time', 5 => 'creative_id', 6 => 'zone_id', 7 => 'ip_address', 8 => 'action', 9 => 'window', 10 => 'status'), 'destination' => array(0 => 'server_raw_tracker_impression_id', 1 => 'server_raw_ip', 2 => 'tracker_id', 3 => 'tracker_date_time', 4 => 'connection_date_time', 5 => 'ad_id', 6 => 'zone_id', 7 => 'tracker_ip_address', 8 => 'connection_action', 9 => 'connection_window', 10 => 'connection_status'), 'extrasDestination' => array(11 => 'creative_id', 12 => 'inside_window'), 'extrasValue' => array(11 => '0', 12 => '1'));
$aDates = array('start' => new Date('2008-08-21 09:00:00'), 'end' => new Date('2008-08-21 09:59:59'));
// Prepare the DAL object
$oFactory = new OX_Dal_Maintenance_Statistics_Factory();
$oDalMaintenanceStatistics = $oFactory->factory();
// Test 1: Test with an incorrect method name in the mapping array
$savedValue = $aMigrationDetails['method'];
$aMigrationDetails['method'] = 'foo';
$result = $oDalMaintenanceStatistics->summariseBucketsRaw($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRaw() called with migration map method 'foo' != 'raw'.");
$aMigrationDetails['method'] = $savedValue;
// Test 2: Test with a different number of source and destination columns
$savedValue = $aMigrationDetails['destination'][1];
unset($aMigrationDetails['destination'][1]);
$result = $oDalMaintenanceStatistics->summariseBucketsRaw($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRaw() called with different number of 'source' and 'destination' columns.");
$aMigrationDetails['destination'][1] = $savedValue;
// Test 3: Test with a different number of extrasDestination and extrasValue columns
$savedValue = $aMigrationDetails['extrasDestination'][11];
unset($aMigrationDetails['extrasDestination'][11]);
$result = $oDalMaintenanceStatistics->summariseBucketsRaw($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRaw() called with different number of 'extrasDestination' and 'extrasValue' columns.");
$aMigrationDetails['extrasDestination'][11] = $savedValue;
// Test 4: Test with date parameters that are not really dates
$savedValue = $aDates['start'];
$aDates['start'] = 'foo';
$result = $oDalMaintenanceStatistics->summariseBucketsRaw($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRaw() called with invalid start/end date parameters -- not Date objects.");
$aDates['start'] = $savedValue;
$savedValue = $aDates['end'];
$aDates['end'] = 'foo';
$result = $oDalMaintenanceStatistics->summariseBucketsRaw($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRaw() called with invalid start/end date parameters -- not Date objects.");
$aDates['end'] = $savedValue;
// Test 5: Test with invalid start/end dates
$savedValue = $aDates['start'];
$aDates['start'] = new Date('2008-08-21 08:00:00');
$result = $oDalMaintenanceStatistics->summariseBucketsRaw($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRaw() called with invalid start/end date parameters -- not operation interval bounds.");
$aDates['start'] = $savedValue;
$savedValue = $aDates['end'];
$aDates['end'] = new Date('2008-08-22 09:59:59');
$result = $oDalMaintenanceStatistics->summariseBucketsRaw($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRaw() called with invalid start/end date parameters -- not operation interval bounds.");
$aDates['end'] = $savedValue;
// Test 6: Test with an invalid statistics table name
$savedValue = $statisticsTableName;
$statisticsTableName = 'foo';
$result = $oDalMaintenanceStatistics->summariseBucketsRaw($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDREQUEST);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRaw() called with invalid statistics table 'foo'.");
$statisticsTableName = $savedValue;
// Test 7: Test with no data_bkt_a table in the database
$result = $oDalMaintenanceStatistics->summariseBucketsRaw($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDREQUEST);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRaw() called with invalid bucket table '{$aConf['table']['prefix']}data_bkt_a'.");
// Install the openXDeliveryLog plugin, which will create the
// data_bkt_a table required for testing
TestEnv::installPluginPackage('openXDeliveryLog', false);
// Test 8: Test with all tables present, but no data
$result = $oDalMaintenanceStatistics->summariseBucketsRaw($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertEqual($result, 0);
// Insert some data into the data_bkt_a table in the incorrect
// operation interval
$oData_bkt_a = OA_Dal::factoryDO('data_bkt_a');
$oData_bkt_a->server_conv_id = 1;
$oData_bkt_a->server_ip = 'localhost';
$oData_bkt_a->tracker_id = 2;
$oData_bkt_a->date_time = '2008-08-21 08:15:00';
$oData_bkt_a->action_date_time = '2008-08-21 07:15:00';
$oData_bkt_a->creative_id = 3;
$oData_bkt_a->zone_id = 4;
$oData_bkt_a->ip_address = '127.0.0.1';
$oData_bkt_a->action = MAX_CONNECTION_AD_CLICK;
$oData_bkt_a->window = 3600;
//.........这里部分代码省略.........
示例14: testSummariseBucketsRawSupplementary
/**
* A method to test the summariseBucketsRawSupplementary() method.
*/
function testSummariseBucketsRawSupplementary()
{
$aConf =& $GLOBALS['_MAX']['CONF'];
$aConf['maintenance']['operationInterval'] = 60;
// Prepare standard test parameters
$statisticsTableName = $aConf['table']['prefix'] . 'data_intermediate_ad_variable_value';
$aMigrationDetails = array('method' => 'rawSupplementary', 'masterTable' => $aConf['table']['prefix'] . 'data_intermediate_ad_connection', 'masterTablePrimaryKeys' => array(0 => 'data_intermediate_ad_connection_id'), 'bucketTablePrimaryKeys' => array(0 => 'data_intermediate_ad_connection_id'), 'masterTableKeys' => array(0 => 'server_raw_tracker_impression_id', 1 => 'server_raw_ip'), 'bucketTableKeys' => array(0 => 'server_conv_id', 1 => 'server_ip'), 'masterDateTimeColumn' => 'tracker_date_time', 'bucketTable' => $aConf['table']['prefix'] . 'data_bkt_a_var', 'source' => array(0 => 'tracker_variable_id', 1 => 'value'), 'destination' => array(0 => 'tracker_variable_id', 1 => 'value'));
$aDates = array('start' => new Date('2008-08-21 09:00:00'), 'end' => new Date('2008-08-21 09:59:59'));
// Prepare the DAL object
$oFactory = new OX_Dal_Maintenance_Statistics_Factory();
$oDalMaintenanceStatistics = $oFactory->factory();
// Test 1: Test with an incorrect method name in the mapping array
$savedValue = $aMigrationDetails['method'];
$aMigrationDetails['method'] = 'foo';
$result = $oDalMaintenanceStatistics->summariseBucketsRawSupplementary($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRawSupplementary() called with migration map method 'foo' != 'rawSupplementary'.");
$aMigrationDetails['method'] = $savedValue;
// Test 2: Test with a different number of masterTablePrimaryKeys and bucketTablePrimaryKeys columns
$savedValue = $aMigrationDetails['masterTablePrimaryKeys'][0];
unset($aMigrationDetails['masterTablePrimaryKeys'][0]);
$result = $oDalMaintenanceStatistics->summariseBucketsRawSupplementary($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRawSupplementary() called with different number of 'masterTablePrimaryKeys' and 'bucketTablePrimaryKeys' columns.");
$aMigrationDetails['masterTablePrimaryKeys'][0] = $savedValue;
// Test 3: Test with a different number of masterTableKeys and bucketTableKeys columns
$savedValue = $aMigrationDetails['masterTableKeys'][1];
unset($aMigrationDetails['masterTableKeys'][1]);
$result = $oDalMaintenanceStatistics->summariseBucketsRawSupplementary($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRawSupplementary() called with different number of 'masterTableKeys' and 'bucketTableKeys' columns.");
$aMigrationDetails['masterTableKeys'][1] = $savedValue;
// Test 4: Test with a different number of source and destination columns
$savedValue = $aMigrationDetails['destination'][1];
unset($aMigrationDetails['destination'][1]);
$result = $oDalMaintenanceStatistics->summariseBucketsRawSupplementary($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRawSupplementary() called with different number of 'source' and 'destination' columns.");
$aMigrationDetails['destination'][1] = $savedValue;
// Test 5: Test with date parameters that are not really dates
$savedValue = $aDates['start'];
$aDates['start'] = 'foo';
$result = $oDalMaintenanceStatistics->summariseBucketsRawSupplementary($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRawSupplementary() called with invalid start/end date parameters -- not Date objects.");
$aDates['start'] = $savedValue;
$savedValue = $aDates['end'];
$aDates['end'] = 'foo';
$result = $oDalMaintenanceStatistics->summariseBucketsRawSupplementary($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRawSupplementary() called with invalid start/end date parameters -- not Date objects.");
$aDates['end'] = $savedValue;
// Test 6: Test with invalid start/end dates
$savedValue = $aDates['start'];
$aDates['start'] = new Date('2008-08-21 08:00:00');
$result = $oDalMaintenanceStatistics->summariseBucketsRawSupplementary($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRawSupplementary() called with invalid start/end date parameters -- not operation interval bounds.");
$aDates['start'] = $savedValue;
$savedValue = $aDates['end'];
$aDates['end'] = new Date('2008-08-22 09:59:59');
$result = $oDalMaintenanceStatistics->summariseBucketsRawSupplementary($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDARGS);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRawSupplementary() called with invalid start/end date parameters -- not operation interval bounds.");
$aDates['end'] = $savedValue;
// Test 7: Test with an invalid statistics table name
$savedValue = $statisticsTableName;
$statisticsTableName = 'foo';
$result = $oDalMaintenanceStatistics->summariseBucketsRawSupplementary($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDREQUEST);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRawSupplementary() called with invalid statistics table 'foo'.");
$statisticsTableName = $savedValue;
// Test 8: Test with an invalid master statistics table name
$savedValue = $aMigrationDetails['masterTable'];
$aMigrationDetails['masterTable'] = 'foo';
$result = $oDalMaintenanceStatistics->summariseBucketsRawSupplementary($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDREQUEST);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRawSupplementary() called with invalid master table 'foo'.");
$aMigrationDetails['masterTable'] = $savedValue;
// Test 9: Test with no data_bkt_a_var table in the database
$result = $oDalMaintenanceStatistics->summariseBucketsRawSupplementary($statisticsTableName, $aMigrationDetails, $aDates);
$this->assertTrue(is_a($result, 'PEAR_Error'));
$this->assertEqual($result->code, MAX_ERROR_INVALIDREQUEST);
$this->assertEqual($result->message, "OX_Dal_Maintenance_Statistics::summariseBucketsRawSupplementary() called with invalid bucket table '{$aConf['table']['prefix']}data_bkt_a_var'.");
// Install the openXDeliveryLog plugin, which will create the
// data_bkt_a table required for testing
TestEnv::installPluginPackage('openXDeliveryLog', false);
//.........这里部分代码省略.........
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:101,代码来源:Statistics_summariseBucketsRawSupplementary.dal.test.php
示例15: test_MAX_Delivery_log_logConversion
/**
* A method to test the MAX_Delivery_log_logConversion() function.
*/
function test_MAX_Delivery_log_logConversion()
{
$aConf =& $GLOBALS['_MAX']['CONF'];
$aConf['maintenance']['operationInterval'] = 60;
$GLOBALS['_MAX']['NOW'] = time();
$oNowDate = new Date($GLOBALS['_MAX']['NOW']);
$aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oNowDate);
$intervalStart = $aDates['start']->format('%Y-%m-%d %H:%M:%S');
$oConversionDate = new Date();
$oConversionDate->copy($oNowDate);
$oConversionDate->subtractSeconds(60);
$_SERVER['REMOTE_ADDR'] = '127.0.0.99';
// Test to ensure that the openXDeliveryLog plugin's data bucket
// table does not exist
$oTable = new OA_DB_Table();
$tableExists = $oTable->extistsTable($aConf['table']['prefix'] . 'data_bkt_a');
$this->assertFalse($tableExists);
// Test calling the main logging function without any plugins installed,
// to ensure that this does not result in any kind of error
$aConversion = array('action_type' => MAX_CONNECTION_AD_CLICK, 'tracker_type' => MAX_CONNECTION_TYPE_SALE, 'status' => MAX_CONNECTION_STATUS_APPROVED, 'cid' => 2, 'zid' => 3, 'dt' => $GLOBALS['_MAX']['NOW'] - 60, 'window' => 60);
MAX_Delivery_log_logConversion(1, $aConversion);
// Install the openXDeliveryLog plugin
TestEnv::installPluginPackage('openXDeliveryLog', false);
// Test to ensure that the openXDeliveryLog plugin's data bucket
// table now does exist
$tableExists = $oTable->extistsTable($aConf['table']['prefix'] . 'data_bkt_a');
$this->assertTrue($tableExists);
// Ensure that there are is nothing logged in the data bucket table
$doData_bkt_a = OA_Dal::factoryDO('data_bkt_a');
$doData_bkt_a->find();
$rows = $doData_bkt_a->getRowCount();
$this->assertEqual($rows, 0);
// Call the conversion logging function
$aConversionInfo = MAX_Delivery_log_logConversion(1, $aConversion);
// Ensure that the data was logged correctly
$doData_bkt_a = OA_Dal::factoryDO('data_bkt_a');
$doData_bkt_a->find();
$rows = $doData_bkt_a->getRowCount();
$this->assertEqual($rows, 1);
$doData_bkt_a = OA_Dal::factoryDO('data_bkt_a');
$doData_bkt_a->server_conv_id = 1;
$doData_bkt_a->find();
$rows = $doData_bkt_a->getRowCount();
$this->assertEqual($rows, 1);
$doData_bkt_a->fetch();
$this->assertEqual($doData_bkt_a->server_ip, 'singleDB');
$this->assertEqual($doData_bkt_a->tracker_id, 1);
$this->assertEqual($doData_bkt_a->date_time, $oNowDate->format('%Y-%m-%d %H:%M:%S'));
$this->assertEqual($doData_bkt_a->action_date_time, $oConversionDate->format('%Y-%m-%d %H:%M:%S'));
$this->assertEqual($doData_bkt_a->creative_id, 2);
$this->assertEqual($doData_bkt_a->zone_id, 3);
$this->assertEqual($doData_bkt_a->ip_address, '127.0.0.99');
$this->assertEqual($doData_bkt_a->action, MAX_CONNECTION_AD_CLICK);
$this->assertEqual($doData_bkt_a->window, 60);
$this->assertEqual($doData_bkt_a->status, MAX_CONNECTION_STATUS_APPROVED);
$this->assertTrue(is_array($aConversionInfo));
$this->assertTrue(is_array($aConversionInfo['deliveryLog:oxLogConversion:logConversion']));
$this->assertEqual($aConversionInfo['deliveryLog:oxLogConversion:logConversion']['server_conv_id'], 1);
$this->assertEqual($aConversionInfo['deliveryLog:oxLogConversion:logConversion']['server_raw_ip'], 'singleDB');
$aConversion['cid'] = 5;
// Call the conversion logging function
$aConversionInfo = MAX_Delivery_log_logConversion(1, $aConversion);
// Ensure that the data was logged correctly
$doData_bkt_a = OA_Dal::factoryDO('data_bkt_a');
$doData_bkt_a->find();
$rows = $doData_bkt_a->getRowCount();
$this->assertEqual($rows, 2);
$doData_bkt_a = OA_Dal::factoryDO('data_bkt_a');
$doData_bkt_a->server_conv_id = 1;
$doData_bkt_a->find();
$rows = $doData_bkt_a->getRowCount();
$this->assertEqual($rows, 1);
$doData_bkt_a->fetch();
$this->assertEqual($doData_bkt_a->server_ip, 'singleDB');
$this->assertEqual($doData_bkt_a->tracker_id, 1);
$this->assertEqual($doData_bkt_a->date_time, $oNowDate->format('%Y-%m-%d %H:%M:%S'));
$this->assertEqual($doData_bkt_a->action_date_time, $oConversionDate->format('%Y-%m-%d %H:%M:%S'));
$this->assertEqual($doData_bkt_a->creative_id, 2);
$this->assertEqual($doData_bkt_a->zone_id, 3);
$this->assertEqual($doData_bkt_a->ip_address, '127.0.0.99');
$this->assertEqual($doData_bkt_a->action, MAX_CONNECTION_AD_CLICK);
$this->assertEqual($doData_bkt_a->window, 60);
$this->assertEqual($doData_bkt_a->status, MAX_CONNECTION_STATUS_APPROVED);
$doData_bkt_a = OA_Dal::factoryDO('data_bkt_a');
$doData_bkt_a->server_conv_id = 2;
$doData_bkt_a->find();
$rows = $doData_bkt_a->getRowCount();
$this->assertEqual($rows, 1);
$doData_bkt_a->fetch();
$this->assertEqual($doData_bkt_a->server_ip, 'singleDB');
$this->assertEqual($doData_bkt_a->tracker_id, 1);
$this->assertEqual($doData_bkt_a->date_time, $oNowDate->format('%Y-%m-%d %H:%M:%S'));
$this->assertEqual($doData_bkt_a->action_date_time, $oConversionDate->format('%Y-%m-%d %H:%M:%S'));
$this->assertEqual($doData_bkt_a->creative_id, 5);
$this->assertEqual($doData_bkt_a->zone_id, 3);
$this->assertEqual($doData_bkt_a->ip_address, '127.0.0.99');
$this->assertEqual($doData_bkt_a->action, MAX_CONNECTION_AD_CLICK);
//.........这里部分代码省略.........