本文整理汇总了PHP中DataGenerator::generateOne方法的典型用法代码示例。如果您正苦于以下问题:PHP DataGenerator::generateOne方法的具体用法?PHP DataGenerator::generateOne怎么用?PHP DataGenerator::generateOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataGenerator
的用法示例。
在下文中一共展示了DataGenerator::generateOne方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdateVariableCode
function testUpdateVariableCode()
{
$this->varName = 'my_var';
$this->defaultVarCode = "var {$this->varName} = escape(\\'%%" . strtoupper($this->varName) . "_VALUE%%\\')";
// Create a tracker with default variableMethod
$doTrackers = OA_Dal::factoryDO('trackers');
$trackerId = DataGenerator::generateOne($doTrackers);
$doVariables = OA_Dal::factoryDO('variables');
$doVariables->trackerid = $trackerId;
$doVariables->name = $this->varName;
$doVariables->variablecode = $this->defaultVarCode;
$aVariableIds = DataGenerator::generate($doVariables, 2);
// JS
$this->assertTrue($this->dalVariables->updateVariableCode($trackerId, DataObjects_Trackers::TRACKER_VARIABLE_METHOD_JS));
$this->assertVariableCode($trackerId, DataObjects_Trackers::TRACKER_VARIABLE_METHOD_JS);
// DOM
$this->assertTrue($this->dalVariables->updateVariableCode($trackerId, DataObjects_Trackers::TRACKER_VARIABLE_METHOD_DOM));
$this->assertVariableCode($trackerId, DataObjects_Trackers::TRACKER_VARIABLE_METHOD_DOM);
// Custom
$this->customCode = 'custom';
$doVariables->variablecode = $this->customCode;
$doVariables->whereAdd('1=1');
$doVariables->update(DB_DATAOBJECT_WHEREADD_ONLY);
$this->assertTrue($this->dalVariables->updateVariableCode($trackerId, DataObjects_Trackers::TRACKER_VARIABLE_METHOD_CUSTOM));
$this->assertVariableCode($trackerId, DataObjects_Trackers::TRACKER_VARIABLE_METHOD_CUSTOM);
// Default
$this->assertTrue($this->dalVariables->updateVariableCode($trackerId));
$this->assertVariableCode($trackerId);
}
示例2: md5
function &staticGetApi($createDefaultManager = true)
{
$oApi =& $GLOBALS['_STATIC']['staticGetApi'];
if (empty($oApi)) {
$doAccounts = OA_Dal::factoryDO('accounts');
$doAccounts->account_type = OA_ACCOUNT_ADMIN;
$adminAccountId = DataGenerator::generateOne($doAccounts);
if ($createDefaultManager) {
$doAgency = OA_Dal::factoryDO('agency');
$doAgency->name = 'Default Manager';
$agencyId = DataGenerator::generateOne($doAgency);
$doAgency = OA_Dal::staticGetDO('agency', $agencyId);
$managerAccountId = $doAgency->account_id;
}
$doUsers = OA_Dal::factoryDO('users');
$doUsers->username = 'admin_' . md5(uniqid('', true));
$doUsers->password = md5('secret');
$doUsers->default_account_id = $createDefaultManager ? $managerAccountId : $adminAccountId;
$userId = DataGenerator::generateOne($doUsers);
$doAUA = OA_Dal::factoryDO('account_user_assoc');
$doAUA->account_id = $adminAccountId;
$doAUA->user_id = $userId;
DataGenerator::generateOne($doAUA);
$oApi = new Mocked_OA_Api_Xmlrpc($doUsers->username, 'secret');
}
return $oApi;
}
示例3: testUpdate
/**
* Tests the timestamps are updated correctly.
*
* Test 1: Tests the current timestamp is inserted for a new image.
* Test 2: Tests the timestamp is updated when an image is updated.
*
*/
function testUpdate()
{
// Test 1
// Get the start time of the test
$start = time();
sleep(1);
// Insert an image
$doImages = OA_Dal::factoryDO('images');
$doImages->filename = 'foo.jpg';
$doImages->contents = '';
DataGenerator::generateOne($doImages);
// Get the image out of the DB
$doImages = OA_Dal::staticGetDO('images', 'filename', 'foo.jpg');
// Check the timestamp is > time at start of test and <= current time
// Deal with MySQL 4.0 timestamps
if (preg_match('/^(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)$/', $doImages->t_stamp, $m)) {
$doImages->t_stamp = "{$m[1]}-{$m[2]}-{$m[3]} {$m[4]}:{$m[5]}:{$m[6]}";
}
$actual = strtotime($doImages->t_stamp);
$this->assertTrue($actual > $start && $actual <= time());
// Test 2
// Update the image
$doImages->contents = '1';
sleep(1);
$doImages->update();
// Get the image out of the DB
$doImages = OA_Dal::staticGetDO('images', 'filename', 'foo.jpg');
$oldTime = $actual;
// Deal with MySQL 4.0 timestamps
if (preg_match('/^(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)$/', $doImages->t_stamp, $m)) {
$doImages->t_stamp = "{$m[1]}-{$m[2]}-{$m[3]} {$m[4]}:{$m[5]}:{$m[6]}";
}
$actual = strtotime($doImages->t_stamp);
$this->assertTrue($actual > $oldTime && $actual <= time());
}
示例4: testUpdateWhereOne
function testUpdateWhereOne()
{
$this->initTables(array('campaigns', 'trackers'));
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = 'First';
$doCampaigns->views = 10;
$campaignId1 = DataGenerator::generateOne($doCampaigns);
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = 'Third';
$doCampaigns->views = 30;
$campaignId2 = DataGenerator::generateOne($doCampaigns);
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = 'Fifth';
$doCampaigns->views = 50;
$campaignId3 = DataGenerator::generateOne($doCampaigns);
$cUpdated = OA_DB_Sql::updateWhereOne('campaigns', 'campaignid', $campaignId2, array('campaignname' => 'Second', 'views' => 20));
$this->assertEqual(1, $cUpdated);
$doCampaigns = OA_Dal::staticGetDO('campaigns', $campaignId2);
$this->assertEqual('Second', $doCampaigns->campaignname);
$this->assertEqual(20, $doCampaigns->views);
$doCampaigns = OA_Dal::staticGetDO('campaigns', $campaignId1);
$this->assertEqual('First', $doCampaigns->campaignname);
$this->assertEqual('10', $doCampaigns->views);
$aConf = $GLOBALS['_MAX']['CONF'];
$this->oaTable->dropTable($aConf['table']['prefix'] . 'campaigns');
$this->oaTable->dropTable($aConf['table']['prefix'] . 'trackers');
}
示例5: addAdZoneAssoc
function addAdZoneAssoc($adId, $zoneId, $priority)
{
$doAd_zone_assoc = OA_Dal::factoryDO('ad_zone_assoc');
$doAd_zone_assoc->ad_id = $adId;
$doAd_zone_assoc->zone_id = $zoneId;
$doAd_zone_assoc->priority = $priority;
DataGenerator::generateOne($doAd_zone_assoc);
}
示例6: testDuplicate
function testDuplicate()
{
$GLOBALS['strCopyOf'] = 'Copy of ';
// create test channel
$doChannel = OA_Dal::factoryDO('channel');
$doChannel->acls_updated = '2007-04-03 19:29:54';
$channelId = DataGenerator::generateOne($doChannel, true);
// create test acls
$doAcls = OA_Dal::factoryDO('acls_channel');
$doAcls->channelid = $channelId;
$doAcls->type = 'Client:Ip';
$doAcls->comparison = '==';
$doAcls->data = '127.0.0.1';
$doAcls->executionorder = 1;
$doAcls->insert();
$doAcls = OA_Dal::factoryDO('acls_channel');
$doAcls->channelid = $channelId;
$doAcls->type = 'Client:Domain';
$doAcls->comparison = '==';
$doAcls->data = 'example.com';
$doAcls->executionorder = 2;
$doAcls->insert();
// duplicate
$newChannelId = OA_Dal::staticDuplicate('channel', $channelId);
// retrieve original and duplicate channel
$doChannel = OA_Dal::staticGetDO('channel', $channelId);
$doNewChannel = OA_Dal::staticGetDO('channel', $newChannelId);
// assert they are not equal including primary keys - name column should not match
$this->assertNotEqualDataObjects($this->stripKeys($doChannel), $this->stripKeys($doNewChannel));
// assert they are equal excluding primary keys
$doChannel->name = $doNewChannel->name = null;
$this->assertEqualDataObjects($this->stripKeys($doChannel), $this->stripKeys($doNewChannel));
// retrieve acls for original and duplicate channel
$doAcls = OA_Dal::factoryDO('acls_channel');
$doAcls->channelid = $channelId;
$doAcls->orderBy('executionorder');
if ($doAcls->find()) {
while ($doAcls->fetch()) {
$aAcls[] = clone $doAcls;
}
}
$doNewAcls = OA_Dal::factoryDO('acls_channel');
$doNewAcls->channelid = $newChannelId;
$doNewAcls->orderBy('executionorder');
if ($doNewAcls->find()) {
while ($doNewAcls->fetch()) {
$aNewAcls[] = clone $doNewAcls;
}
}
// iterate through acls ensuring they were properly copied
if ($this->assertEqual(count($aAcls), count($aNewAcls))) {
for ($x = 0; $x < count($aAcls); $x++) {
$this->assertNotEqual($aAcls[$x]->channelid, $aNewAcls[$x]->channelid);
$this->assertEqualDataObjects($this->stripKeys($aAcls[$x]), $this->stripKeys($aNewAcls[$x]));
}
}
}
示例7: testDuplicate
function testDuplicate()
{
// Insert a tracker with some default data.
$doTrackers = OA_Dal::factoryDO('trackers');
$doTrackers->trackername = 'foo';
$doTrackers->clientid = 1;
$doTrackers->clickwindow = 3600;
$doTrackers->status = 4;
$doTrackers->type = 1;
$trackerId = DataGenerator::generateOne($doTrackers, true);
// Insert a variable for the tracker
$doVariables = OA_Dal::factoryDO('variables');
$doVariables->trackerid = $trackerId;
$doVariables->name = 'bar';
$variableId = DataGenerator::generateOne($doVariables);
// Link the tracker to a campaign
$doCampaignTrackers = OA_Dal::factoryDO('campaigns_trackers');
$doCampaignTrackers->campaignid = 1;
$doCampaignTrackers->trackerid = $trackerId;
$campaignTrackerId = DataGenerator::generateOne($doCampaignTrackers);
// Duplicate the tracker
$doTrackers = OA_Dal::staticGetDO('trackers', $trackerId);
$newTrackerId = $doTrackers->duplicate();
$this->assertNotEmpty($newTrackerId);
// Get the two trackers
$doNewTrackers = OA_Dal::staticGetDO('trackers', $newTrackerId);
$this->assertTrue($doNewTrackers);
$doTrackers = OA_Dal::staticGetDO('trackers', $trackerId);
$this->assertTrue($doTrackers);
// Assert the trackers are not equal, excluding the primary key
$this->assertNotEqualDataObjects($this->stripKeys($doTrackers), $this->stripKeys($doNewTrackers));
// Assert the only difference in the trackers is their description
$doTrackers->trackername = $doNewTrackers->trackername = null;
$this->assertEqualDataObjects($this->stripKeys($doTrackers), $this->stripKeys($doNewTrackers));
// Get the two variables
$doNewVariables = OA_Dal::staticGetDO('variables', 'trackerid', $newTrackerId);
$this->assertTrue($doNewVariables);
$doVariables = OA_Dal::staticGetDO('variables', $variableId);
$this->assertTrue($doVariables);
// Assert the variables are not equal, excluding the primary key
$this->assertNotEqualDataObjects($this->stripKeys($doVariables), $this->stripKeys($doNewVariables));
// Assert the only difference in the variables is the trackers they are attached to
$doVariables->trackerid = $doNewVariables->trackerid = null;
$this->assertEqualDataObjects($this->stripKeys($doVariables), $this->stripKeys($doNewVariables));
// Get the two campaign tracker links
$doNewCampaignTrackers = OA_Dal::staticGetDO('campaigns_trackers', 'trackerid', $newTrackerId);
$this->assertTrue($doNewCampaignTrackers);
$doCampaignTrackers = OA_Dal::staticGetDO('campaigns_trackers', $campaignTrackerId);
$this->assertTrue($doCampaignTrackers);
// Assert the campaign trackers are not equal, excluding the primary key
$this->assertNotEqualDataObjects($this->stripKeys($doCampaignTrackers), $this->stripKeys($doNewCampaignTrackers));
// Assert the only difference in the campaign trackers is the trackers they are attached to
$doCampaignTrackers->trackerid = $doNewCampaignTrackers->trackerid = null;
$this->assertEqualDataObjects($this->stripKeys($doCampaignTrackers), $this->stripKeys($doNewCampaignTrackers));
DataGenerator::cleanUp(array('campaigns', 'campaigns_trackers', 'trackers', 'variables'));
}
示例8: _insertDataSummaryAdHourly
function _insertDataSummaryAdHourly($aData)
{
$aData['date_time'] = sprintf('%s %02d:00:00', $aData['day'], $aData['hour']);
unset($aData['day']);
unset($aData['hour']);
foreach ($aData as $key => $val) {
$this->doDSAH->{$key} = $val;
}
return DataGenerator::generateOne($this->doDSAH);
}
示例9: _testImageServe
function _testImageServe($timeZone)
{
OA_setTimeZone($timeZone);
$fileName = 'tz_test.gif';
$doImages = OA_Dal::factoryDO('images');
$doImages->filename = $fileName;
$doImages->contents = '';
$this->assertTrue(DataGenerator::generateOne($doImages));
$now = time();
$this->assertTrue($timeZone == 'UTC' || date('Z', $now), 'Time zone not correctly set');
// Simulate delivery
OA_setTimeZoneUTC();
$aCreative = OA_Dal_Delivery_getCreative($fileName);
$this->assertTrue($aCreative);
// Serve with no If-Modified-Since header
unset($GLOBALS['_HEADERS']);
unset($_SERVER['HTTP_IF_MODIFIED_SINCE']);
MAX_imageServe($aCreative, $fileName, 'gif');
if ($this->assertEqual(count($GLOBALS['_HEADERS']), 2, 'Mismatching headers with ' . $timeZone)) {
$this->assertPattern('/^Last-Modified: /i', $GLOBALS['_HEADERS'][0]);
$this->assertPattern('/^Content-Type: /i', $GLOBALS['_HEADERS'][1]);
}
// 1-day old If-Modified-Since header
unset($GLOBALS['_HEADERS']);
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now - 86400) . ' GMT';
MAX_imageServe($aCreative, $fileName, 'gif');
if ($this->assertEqual(count($GLOBALS['_HEADERS']), 2, 'Mismatching headers with ' . $timeZone)) {
$this->assertPattern('/^Last-Modified: /i', $GLOBALS['_HEADERS'][0]);
$this->assertPattern('/^Content-Type: /i', $GLOBALS['_HEADERS'][1]);
}
// 1-day future If-Modified-Since header
unset($GLOBALS['_HEADERS']);
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now + 86400) . ' GMT';
MAX_imageServe($aCreative, $fileName, 'gif');
if ($this->assertEqual(count($GLOBALS['_HEADERS']), 1, 'Mismatching headers with ' . $timeZone)) {
$this->assertPattern('/^HTTP\\/1.0 304/i', $GLOBALS['_HEADERS'][0]);
}
// 1 minute ago If-Modified-Since header
unset($GLOBALS['_HEADERS']);
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now - 60) . ' GMT';
MAX_imageServe($aCreative, $fileName, 'gif');
if ($this->assertEqual(count($GLOBALS['_HEADERS']), 2, 'Mismatching headers with ' . $timeZone)) {
$this->assertPattern('/^Last-Modified: /i', $GLOBALS['_HEADERS'][0]);
$this->assertPattern('/^Content-Type: /i', $GLOBALS['_HEADERS'][1]);
}
// 1 minute in future If-Modified-Since header
unset($GLOBALS['_HEADERS']);
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now + 60) . ' GMT';
MAX_imageServe($aCreative, $fileName, 'gif');
if ($this->assertEqual(count($GLOBALS['_HEADERS']), 1, 'Mismatching headers with ' . $timeZone)) {
$this->assertPattern('/^HTTP\\/1.0 304/i', $GLOBALS['_HEADERS'][0]);
}
}
示例10: _insertCampaignBanner
function _insertCampaignBanner()
{
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->priority = 1;
$doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
$campaignId = DataGenerator::generateOne($doCampaigns);
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->campaignid = $campaignId;
$doBanners->status = OA_ENTITY_STATUS_RUNNING;
$bannerId = DataGenerator::generateOne($doBanners);
return $bannerId;
}
示例11: test_DeliveryDB_getAdminTZ
function test_DeliveryDB_getAdminTZ()
{
// Create the admin account
$doAccounts = OA_Dal::factoryDO('accounts');
$doAccounts->account_name = 'System Administrator';
$doAccounts->account_type = OA_ACCOUNT_ADMIN;
$adminAccountId = DataGenerator::generateOne($doAccounts);
$aExpect = array('default' => 'UTC', 'aAccounts' => array(), 'adminAccountId' => 1);
$aResult = OA_Dal_Delivery_getAccountTZs();
$this->assertEqual($aResult, $aExpect);
$doPreferences = OA_Dal::factoryDO('preferences');
$doPreferences->preference_name = 'timezone';
$preferenceId = $doPreferences->insert();
$doAPA = OA_Dal::factoryDO('account_preference_assoc');
$doAPA->account_id = $adminAccountId;
$doAPA->preference_id = $preferenceId;
$doAPA->value = '';
$doAPA->insert();
$aResult = OA_Dal_Delivery_getAccountTZs();
$this->assertEqual($aResult, $aExpect);
$doAPA = OA_Dal::factoryDO('account_preference_assoc');
$doAPA->account_id = $adminAccountId;
$doAPA->preference_id = $preferenceId;
$doAPA->value = 'Europe/Rome';
$doAPA->update();
$aExpect = array('default' => 'Europe/Rome', 'aAccounts' => array(), 'adminAccountId' => 1);
$aResult = OA_Dal_Delivery_getAccountTZs();
$this->assertEqual($aResult, $aExpect);
// Create a couple of manager accounts
$doAccounts = OA_Dal::factoryDO('accounts');
$doAccounts->account_name = 'Manager Account 1';
$doAccounts->account_type = OA_ACCOUNT_MANAGER;
$managerAccountId1 = DataGenerator::generateOne($doAccounts);
$doAPA = OA_Dal::factoryDO('account_preference_assoc');
$doAPA->account_id = $managerAccountId1;
$doAPA->preference_id = $preferenceId;
$doAPA->value = 'Europe/London';
$doAPA->insert();
$doAccounts = OA_Dal::factoryDO('accounts');
$doAccounts->account_name = 'Manager Account 2';
$doAccounts->account_type = OA_ACCOUNT_MANAGER;
$managerAccountId2 = DataGenerator::generateOne($doAccounts);
$doAPA = OA_Dal::factoryDO('account_preference_assoc');
$doAPA->account_id = $managerAccountId2;
$doAPA->preference_id = $preferenceId;
$doAPA->value = 'CEST';
$doAPA->insert();
$aExpect = array('default' => 'Europe/Rome', 'aAccounts' => array($managerAccountId1 => 'Europe/London', $managerAccountId2 => 'CEST'), 'adminAccountId' => 1);
$aResult = OA_Dal_Delivery_getAccountTZs();
$this->assertEqual($aResult, $aExpect);
}
示例12: setUp
/**
* A method to be run before all tests.
*/
function setUp()
{
// Set up the database handler object
$this->oDbh =& OA_DB::singleton();
$doCampaigns = OA_Dal::factoryDO('campaigns');
$aIds = DataGenerator::generate($doCampaigns, 2);
$this->idCampaign1 = $aIds[0];
$this->idCampaign2 = $aIds[1];
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->campaignid = $this->idCampaign1;
$this->idBanner1 = DataGenerator::generateOne($doBanners);
$doBanners->campaignid = $this->idCampaign2;
$this->idBanner2 = DataGenerator::generateOne($doBanners);
}
示例13: testClearIntermediateAndSummaryTables
function testClearIntermediateAndSummaryTables()
{
$oStartDate = new Date('2006-05-09 13:00:00');
$oEndDate = new Date('2006-05-09 13:59:59');
$aTestDates = array(1 => array('start' => new Date('2006-05-09 13:10:00'), 'end' => new Date('2006-05-09 13:14:59')), 2 => array('start' => new Date('2006-05-09 12:00:00'), 'end' => new Date('2006-05-09 12:59:59')), 3 => array('start' => new Date('2006-05-09 13:55:00'), 'end' => new Date('2006-05-09 12:59:59')));
// Create some test data
foreach ($aTestDates as $key => $aDates) {
$doIntermediateAdConnection = OA_Dal::factoryDO('data_intermediate_ad_connection');
$doIntermediateAdConnection->tracker_date_time = $aDates['start']->format('%Y-%m-%d %H:%M:%S');
$aIntermediateAdConnectionId[$key] = DataGenerator::generateOne($doIntermediateAdConnection);
$doDataIntermediateAdVariableValue = OA_Dal::factoryDO('data_intermediate_ad_variable_value');
$doDataIntermediateAdVariableValue->data_intermediate_ad_connection_id = $aIntermediateAdConnectionId[$key];
$aDataIntermediateAdVariableValueId[$key] = DataGenerator::generateOne($doDataIntermediateAdVariableValue);
$doDataIntermediateAd = OA_Dal::factoryDO('data_intermediate_ad');
$doDataIntermediateAd->interval_start = $aDates['start']->format('%Y-%m-%d %H:%M:%S');
$doDataIntermediateAd->interval_end = $aDates['end']->format('%Y-%m-%d %H:%M:%S');
$aDataIntermediateAdId[$key] = DataGenerator::generateOne($doDataIntermediateAd);
$doDataSummaryAdHourly = OA_Dal::factoryDO('data_summary_ad_hourly');
$doDataSummaryAdHourly->date_time = $aDates['start']->format('%Y-%m-%d %H:00:00');
$aDataSummaryAdHourlyId[$key] = DataGenerator::generateOne($doDataSummaryAdHourly);
$doDataSummaryAdZoneAssoc = OA_Dal::factoryDO('data_summary_ad_zone_assoc');
$doDataSummaryAdZoneAssoc->interval_start = $aDates['start']->format('%Y-%m-%d %H:%M:%S');
$doDataSummaryAdZoneAssoc->interval_end = $aDates['end']->format('%Y-%m-%d %H:%M:%S');
$aDataSummaryAdZoneAssocId[$key] = DataGenerator::generateOne($doDataSummaryAdZoneAssoc);
}
OA_Maintenance_Regenerate::clearIntermediateAndSummaryTables($oStartDate, $oEndDate);
// Check if proper rows was deleted
foreach ($aIntermediateAdConnectionId as $key => $intermediateAdConnectionId) {
$adoIntermediateAdConnection[$key] = OA_Dal::staticGetDO('data_intermediate_ad_connection', $aIntermediateAdConnectionId[$key]);
$adoDataIntermediateAdVariableValue[$key] = OA_Dal::staticGetDO('data_intermediate_ad_variable_value', $aDataIntermediateAdVariableValueId[$key]);
$adoDataIntermediateAd[$key] = OA_Dal::staticGetDO('data_intermediate_ad', $aDataIntermediateAdId[$key]);
$adoDataSummaryAdHourly[$key] = OA_Dal::staticGetDO('data_summary_ad_hourly', $aDataSummaryAdHourlyId[$key]);
$adoDataSummaryAdZoneAssoc[$key] = OA_Dal::staticGetDO('data_summary_ad_zone_assoc', $aDataSummaryAdZoneAssocId[$key]);
}
$this->assertFalse($adoIntermediateAdConnection[1]);
$this->assertFalse($adoDataIntermediateAdVariableValue[1]);
$this->assertFalse($adoDataIntermediateAd[1]);
$this->assertFalse($adoDataSummaryAdHourly[1]);
$this->assertFalse($adoDataSummaryAdZoneAssoc[1]);
$this->assertNotNull($adoIntermediateAdConnection[2]);
$this->assertNotNull($adoDataIntermediateAdVariableValue[2]);
$this->assertNotNull($adoDataIntermediateAd[2]);
$this->assertNotNull($adoDataSummaryAdHourly[2]);
$this->assertNotNull($adoDataSummaryAdZoneAssoc[2]);
$this->assertFalse($adoIntermediateAdConnection[3]);
$this->assertFalse($adoDataIntermediateAdVariableValue[3]);
$this->assertFalse($adoDataIntermediateAd[3]);
$this->assertFalse($adoDataSummaryAdHourly[3]);
$this->assertFalse($adoDataSummaryAdZoneAssoc[3]);
}
示例14: test_relinkOrDeleteUsers
/**
* Test method _relinkOrDeleteUsers
*/
function test_relinkOrDeleteUsers()
{
// Insert an agency
$doAgency = OA_Dal::factoryDO('agency');
$agencyId = DataGenerator::generateOne($doAgency);
$managerAccountId = DataGenerator::getReferenceId('accounts');
$doAgency = OA_Dal::factoryDO('agency');
$doAgency->get($agencyId);
$managerAccountId = $doAgency->account_id;
// Create admin account
$doAccounts = OA_Dal::factoryDO('accounts');
$doAccounts->account_type = OA_ACCOUNT_ADMIN;
$adminAccountId = DataGenerator::generateOne($doAccounts);
// Create user linked to admin account
// Default account for this user is set to manager account
$doUsers = OA_Dal::factoryDO('users');
$doUsers->default_account_id = $managerAccountId;
$doUsers->username = 'admin';
$adminUserID = DataGenerator::generateOne($doUsers);
$doAccountsUserAssoc = OA_Dal::factoryDO('account_user_assoc');
$doAccountsUserAssoc->account_id = $adminAccountId;
$doAccountsUserAssoc->user_id = $adminUserID;
DataGenerator::generateOne($doAccountsUserAssoc);
// Create manager user
$doUsers = OA_Dal::factoryDO('users');
$doUsers->default_account_id = $managerAccountId;
$doUsers->username = 'manager';
$managerUserID = DataGenerator::generateOne($doUsers);
// Now delete Agency
$doAgency = OA_Dal::factoryDO('agency');
$doAgency->agencyid = $agencyId;
$doAgency->onDeleteCascade = false;
// Disable cascade delete
$doAgency->delete();
$doAccounts = OA_Dal::factoryDO('accounts');
$doAccounts->get($managerAccountId);
// Relink / Delete users here
$doAccounts->_relinkOrDeleteUsers();
// Test: admin user exists, linked to admin account
$doUsers = OA_Dal::factoryDO('users');
$doUsers->user_id = $adminUserID;
$doUsers->find();
$this->assertTrue($doUsers->fetch());
$this->assertEqual($doUsers->default_account_id, $adminAccountId);
// Test: manager users is deleted
$doUsers = OA_Dal::factoryDO('users');
$doUsers->user_id = $managerUserID;
$doUsers->find();
$this->assertFalse($doUsers->fetch());
}
示例15: testStaticGetDO
function testStaticGetDO()
{
// create test record
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->acls_updated = '2007-04-03 20:41:33';
$bannerId = DataGenerator::generateOne($doBanners);
// Test that we retreived that record from database
$doBanners = OA_Dal::staticGetDO('banners', $bannerId);
$this->assertIsA($doBanners, 'DataObjects_Banners');
$this->assertEqual($doBanners->bannerid, $bannerId);
// Test that false is returned if record doesn't exist
$doBanners = OA_Dal::staticGetDO('banners', $id = 123);
$this->assertFalse($doBanners);
}