本文整理汇总了PHP中DataGenerator::getReferenceId方法的典型用法代码示例。如果您正苦于以下问题:PHP DataGenerator::getReferenceId方法的具体用法?PHP DataGenerator::getReferenceId怎么用?PHP DataGenerator::getReferenceId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataGenerator
的用法示例。
在下文中一共展示了DataGenerator::getReferenceId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAll
function testGetAll()
{
// test it returns empty array when no data
$doCampaigns = OA_Dal::factoryDO('campaigns');
$aCheck = $doCampaigns->getAll();
$this->assertEqual($aCheck, array());
// Insert campaigns with default data
// and few additional records required for testing filters
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = $campaignName = 'test name';
$aData = array('reportlastdate' => array('2007-04-03 18:39:45'));
$dg = new DataGenerator();
$dg->setData('clients', $aData);
$aCampaignId = $dg->generate($doCampaigns, 2, true);
$clientId = DataGenerator::getReferenceId('clients');
$aCampaignId2 = $dg->generate('campaigns', 2, true);
$clientId2 = DataGenerator::getReferenceId('clients');
// test getting all records
$doCampaigns = OA_Dal::factoryDO('campaigns');
$aCheck = $doCampaigns->getAll();
$this->assertEqual(count($aCheck), 4);
$doCampaignsFilter = OA_Dal::factoryDO('campaigns');
$doCampaignsFilter->clientid = $clientId;
// test filtering and test that rows are not indexed by primary key
$doCampaigns = clone $doCampaignsFilter;
$aCheck = $doCampaigns->getAll();
$this->assertEqual(count($aCheck), count($aCampaignId));
$this->assertEqual(array_keys($aCheck), array(0, 1));
// test indexing with primary keys
$doCampaigns = clone $doCampaignsFilter;
$aCheck = $doCampaigns->getAll(array(), $indexWithPrimaryKey = true);
$aTest = array_keys($aCheck);
sort($aTest);
$this->assertEqual($aCampaignId, $aTest);
foreach ($aCheck as $check) {
$this->assertEqual($check['campaignname'], $campaignName);
}
// test flattening if only one field
$doCampaigns = clone $doCampaignsFilter;
$aCheck = $doCampaigns->getAll(array('campaignname'), $indexWithPrimaryKey = false, $flatten = true);
foreach ($aCheck as $check) {
$this->assertEqual($check, $campaignName);
}
// test that we don't have to use array if only one field is set
$doCampaigns = clone $doCampaignsFilter;
$aCheck2 = $doCampaigns->getAll('campaignname', $indexWithPrimaryKey = false, $flatten = true);
$this->assertEqual($aCheck, $aCheck2);
// test we could index by any field - not only by primary key
$doCampaigns = OA_Dal::factoryDO('campaigns');
$aCheck = $doCampaigns->getAll('campaignname', $indexBy = 'clientid', $flatten = true);
$this->assertEqual(count($aCheck), 2);
$this->assertEqual(array_keys($aCheck), array($clientId, $clientId2));
}
示例2: 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());
}
示例3: testGetAllCampaignsUnderAgency
function testGetAllCampaignsUnderAgency()
{
// Test it doesn't return any data if no records are added
$this->assertEqual(count($this->oDalCampaigns->getAllCampaignsUnderAgency(123, 'name', 'up')), 0);
// Add test data (add a little bit more than required)
$numCampaigns1 = 3;
$aData = array('reportlastdate' => array('2007-04-03 18:39:45'));
$dg = new DataGenerator();
$dg->setData('clients', $aData);
$aCampaigns1 = $dg->generate('campaigns', $numCampaigns1, true);
$agencyId1 = DataGenerator::getReferenceId('agency');
$numCampaigns2 = 2;
$aData = array('reportlastdate' => array('2007-04-03 18:39:45'));
$dg = new DataGenerator();
$dg->setData('clients', $aData);
$aCampaigns2 = $dg->generate('campaigns', $numCampaigns2, true);
$agencyId2 = DataGenerator::getReferenceId('agency');
$clientId = DataGenerator::getReferenceId('clients');
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->clientid = $clientId;
$doCampaigns->campaignname = 'market campaign';
$doCampaigns->type = DataObjects_Campaigns::CAMPAIGN_TYPE_MARKET_CAMPAIGN_OPTIN;
$marketCampaignId = DataGenerator::generateOne($doCampaigns);
// Take test data
$aCampaigns = $this->oDalCampaigns->getAllCampaignsUnderAgency($agencyId2, 'name', 'up');
$this->assertEqual(count($aCampaigns), $numCampaigns2);
// Make sure that both arrays have the same sorting
ksort($aCampaigns);
sort($aCampaigns2);
$this->assertEqual(array_keys($aCampaigns), array_values($aCampaigns2));
$aIncludeSystemTypes = array(DataObjects_Campaigns::CAMPAIGN_TYPE_MARKET_CAMPAIGN_OPTIN);
$aCampaigns = $this->oDalCampaigns->getAllCampaignsUnderAgency($agencyId2, 'name', 'up', $aIncludeSystemTypes);
$this->assertEqual(count($aCampaigns), $numCampaigns2 + 1);
}
示例4: testGetBannerByKeyword
function testGetBannerByKeyword()
{
// Search for banners when none exist
$expected = 0;
$rsBanners = $this->dalBanners->getBannerByKeyword('foo');
$rsBanners->find();
$actual = $rsBanners->getRowCount();
$this->assertEqual($actual, $expected);
$agencyId = 1;
$rsBanners = $this->dalBanners->getBannerByKeyword('foo', $agencyId);
$rsBanners->find();
$actual = $rsBanners->getRowCount();
$this->assertEqual($actual, $expected);
// Insert a banner (and it's parent campaign/client)
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->description = 'foo';
$doBanners->alt = 'bar';
$doBanners->campaignid = $campaignId;
$doBanners->ext_bannertype = DataObjects_Banners::BANNER_TYPE_MARKET;
$doBanners->acls_updated = '2007-04-03 18:39:45';
$aData = array('reportlastdate' => array('2007-04-03 18:39:45'));
$dg = new DataGenerator();
$dg->setData('clients', $aData);
$bannerId = $dg->generate($doBanners, 1, true);
$agencyId = $dg->getReferenceId('agency');
// Search for banner by description
$expected = 0;
$rsBanners = $this->dalBanners->getBannerByKeyword('foo');
$rsBanners->find();
$actual = $rsBanners->getRowCount();
$this->assertEqual($actual, $expected);
$expected = 1;
$rsBanners = $this->dalBanners->getBannerByKeyword('foo', null, false);
$rsBanners->find();
$actual = $rsBanners->getRowCount();
$this->assertEqual($actual, $expected);
// Search for banner by alt
$expected = 1;
$rsBanners = $this->dalBanners->getBannerByKeyword('bar', null, false);
$rsBanners->find();
$actual = $rsBanners->getRowCount();
$this->assertEqual($actual, $expected);
// Restrict to agency ID (client was created with default agency ID of 1)
$expected = 1;
$rsBanners = $this->dalBanners->getBannerByKeyword('bar', $agencyId, false);
$rsBanners->find();
$actual = $rsBanners->getRowCount();
$this->assertEqual($actual, $expected);
}
示例5: addAncestor
/**
* Method adds related "parent/ancestor" records recursively.
*
* It should be used only to create records which have only one primary key.
*
* Note: in theory it should work for ancestor records with multiple primary keys
* but this behaviour is undefined.
*
* @param string $table Table name
* @param string $primaryKey Used as primary key for ancestor
* @return int New ID
* @access package private
*/
function addAncestor($table, $primaryKey = null)
{
$doAncestor = OA_Dal::factoryDO($table);
if ($primaryKey && ($primaryKeyField = $doAncestor->getFirstPrimaryKey())) {
// it's possible to preset parent id's (only one level up so far)
$doAncestor->{$primaryKeyField} = $primaryKey;
}
if (!empty($this) && is_a($this, 'DataGenerator')) {
$this->setDefaultValues($doAncestor);
} else {
DataGenerator::setDefaultValues($doAncestor);
}
$links = $doAncestor->links();
foreach ($links as $foreignKey => $linkedTableField) {
list($ancestorTableWithPrefix, $link) = explode(':', $linkedTableField);
$ancestorTable = $doAncestor->getTableWithoutPrefix($ancestorTableWithPrefix);
if (isset($this) && is_a($this, 'DataGenerator')) {
$fieldValue = $this->getFieldValueFromDataContainer($table, $foreignKey);
} else {
$fieldValue = DataGenerator::getFieldValueFromDataContainer($table, $foreignKey);
}
if (isset($fieldValue) && !isset($GLOBALS['dataGeneratorDontOptimize'])) {
//hack for quick test fix
$doAncestor->{$foreignKey} = $fieldValue;
} else {
if (isset($this) && is_a($this, 'DataGenerator')) {
$doAncestor->{$foreignKey} = $this->addAncestor($ancestorTable);
} else {
$doAncestor->{$foreignKey} = DataGenerator::addAncestor($ancestorTable);
}
}
}
DataGenerator::trackData($table);
$id = $doAncestor->insert();
DataGenerator::getReferenceId($table, $id);
// store the id
return $id;
}
示例6: testHasAccessToObject
function testHasAccessToObject()
{
$userTables = array(OA_ACCOUNT_ADVERTISER => 'clients', OA_ACCOUNT_TRAFFICKER => 'affiliates', OA_ACCOUNT_MANAGER => 'agency');
// Test if all users have access to new objects
foreach ($userTables as $userType => $userTable) {
$this->assertTrue(OA_Permission::hasAccessToObject('banners', null, OA_Permission::OPERATION_ALL, rand(1, 100), $userType));
}
// Create some record
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->acls_updated = '2007-04-05 16:18:00';
$aData = array('reportlastdate' => array('2007-04-05 16:18:00'));
$dg = new DataGenerator();
$dg->setData('clients', $aData);
$bannerId = $dg->generateOne($doBanners, true);
$clientId = DataGenerator::getReferenceId('clients');
$doClient = OA_Dal::staticGetDO('clients', $clientId);
$agencyId = DataGenerator::getReferenceId('agency');
$doAgency = OA_Dal::staticGetDO('agency', $agencyId);
// Test that admin doesn't have access anymore to all objects
$this->assertFalse(OA_Permission::hasAccessToObject('banners', 'booId', OA_Permission::OPERATION_ALL, 1, OA_ACCOUNT_ADMIN));
// Test accounts have access
$this->assertTrue(OA_Permission::hasAccessToObject('banners', $bannerId, OA_Permission::OPERATION_ALL, $doClient->account_id, OA_ACCOUNT_ADVERTISER));
$this->assertTrue(OA_Permission::hasAccessToObject('banners', $bannerId, OA_Permission::OPERATION_ALL, $doAgency->account_id, OA_ACCOUNT_MANAGER));
// Create users who don't have access
$doClients = OA_Dal::factoryDO('clients');
$doClients->reportlastdate = '2007-04-05 16:18:00';
$clientId2 = DataGenerator::generateOne($doClients);
$agencyId2 = DataGenerator::generateOne('agency');
$doClientId2 = OA_Dal::staticGetDO('clients', $clientId2);
$doAgency2 = OA_Dal::staticGetDO('agency', $agencyId2);
$this->assertFalse(OA_Permission::hasAccessToObject('banners', $bannerId, $fakeId = 123, OA_Permission::OPERATION_ALL, OA_ACCOUNT_TRAFFICKER));
$this->assertFalse(OA_Permission::hasAccessToObject('banners', $bannerId, $doClientId2->account_id, OA_Permission::OPERATION_ALL, OA_ACCOUNT_ADVERTISER));
$this->assertFalse(OA_Permission::hasAccessToObject('banners', $bannerId, $doAgency2->account_id, OA_Permission::OPERATION_ALL, OA_ACCOUNT_MANAGER));
}
示例7: _commonTest
public function _commonTest($oMaxDalMaintenance, $priority)
{
$oNow = new Date();
$doClients = OA_Dal::factoryDO('clients');
$idClient = DataGenerator::generateOne($doClients, true);
$agencyId1 = DataGenerator::getReferenceId('agency');
// Test 1
$result = $oMaxDalMaintenance->getAgencyCampaignsDeliveriesToDate($agencyId1);
$this->assertTrue(is_array($result));
$this->assertEqual(count($result), 0);
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
$doCampaigns->clientid = $idClient;
$oYesterday = new Date();
$oYesterday->subtractSeconds(86400);
$oTomorrow = new Date();
$oTomorrow->addSeconds(86400);
$doCampaigns->activate_time = $oYesterday->format('%Y-%m-%d %H:%M:%S');
$doCampaigns->expire_time = $oTomorrow->format('%Y-%m-%d %H:%M:%S');
$doCampaigns->priority = '1';
$doCampaigns->active = 1;
$doCampaigns->views = 100;
$doCampaigns->clicks = 200;
$doCampaigns->conversions = 300;
$doCampaigns->updated = $oNow->format('%Y-%m-%d %H:%M:%S');
$idCampaign = DataGenerator::generateOne($doCampaigns);
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->campaignid = $idCampaign;
$doBanners->active = 1;
$doBanners->status = OA_ENTITY_STATUS_RUNNING;
$doBanners->acls_updated = $oNow->format('%Y-%m-%d %H:%M:%S');
$doBanners->updated = $oNow->format('%Y-%m-%d %H:%M:%S');
$idBanner = DataGenerator::generateOne($doBanners);
$doInterAd = OA_Dal::factoryDO('data_intermediate_ad');
$doInterAd->operation_interval = 60;
$doInterAd->operation_interval_id = 0;
$doInterAd->ad_id = $idBanner;
$doInterAd->day = '2005-06-24';
$doInterAd->creative_id = 0;
$doInterAd->zone_id = 1;
$doInterAd->requests = 500;
$doInterAd->impressions = 475;
$doInterAd->clicks = 25;
$doInterAd->conversions = 5;
$doInterAd->updated = $oNow->format('%Y-%m-%d %H:%M:%S');
$doInterAd->interval_start = '2005-06-24 10:00:00';
$doInterAd->date_time = '2005-06-24 10:00:00';
$doInterAd->interval_end = '2005-06-24 10:59:59';
$doInterAd->hour = 10;
$idInterAd = DataGenerator::generateOne($doInterAd);
$doInterAd->interval_start = '2005-06-24 11:00:00';
$doInterAd->date_time = '2005-06-24 11:00:00';
$doInterAd->interval_end = '2005-06-24 11:59:59';
$doInterAd->hour = 11;
$idInterAd = DataGenerator::generateOne($doInterAd);
$result = $oMaxDalMaintenance->getAgencyCampaignsDeliveriesToDate($agencyId1);
$this->assertTrue(is_array($result));
$this->assertEqual(count($result), 1);
foreach ($result as $id => $data) {
$this->assertEqual($idCampaign, $id);
}
$this->assertEqual($result[$idCampaign]['sum_impressions'], 950);
$this->assertEqual($result[$idCampaign]['sum_clicks'], 50);
$this->assertEqual($result[$idCampaign]['sum_conversions'], 10);
// Test 3
$doClients = OA_Dal::factoryDO('clients');
$idClient2 = DataGenerator::generateOne($doClients, true);
$agencyId2 = DataGenerator::getReferenceId('agency');
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->clientid = $idClient2;
$doCampaigns->priority = $priority;
$doCampaigns->ecpm_enabled = 1;
$doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
$doCampaigns->revenue_type = MAX_FINANCE_CPC;
$this->idCampaign2 = DataGenerator::generateOne($doCampaigns);
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->campaignid = $this->idCampaign2;
$doBanners->status = OA_ENTITY_STATUS_RUNNING;
$idBanner2 = DataGenerator::generateOne($doBanners);
$doInterAd->ad_id = $idBanner2;
$idInterAd = DataGenerator::generateOne($doInterAd);
// Check that results for agency 1 are still the same
$result = $oMaxDalMaintenance->getAgencyCampaignsDeliveriesToDate($agencyId1);
$this->assertTrue(is_array($result));
$this->assertEqual(count($result), 1);
foreach ($result as $id => $data) {
$this->assertEqual($idCampaign, $id);
}
$this->assertEqual($result[$idCampaign]['sum_impressions'], 950);
$this->assertEqual($result[$idCampaign]['sum_clicks'], 50);
$this->assertEqual($result[$idCampaign]['sum_conversions'], 10);
// Check results for agency 2
$result = $oMaxDalMaintenance->getAgencyCampaignsDeliveriesToDate($agencyId2);
$this->assertTrue(is_array($result));
$this->assertEqual(count($result), 1);
foreach ($result as $id => $data) {
$this->assertEqual($this->idCampaign2, $id);
}
$this->assertEqual($result[$this->idCampaign2]['sum_impressions'], 475);
$this->assertEqual($result[$this->idCampaign2]['sum_clicks'], 25);
//.........这里部分代码省略.........
开发者ID:Jaree,项目名称:revive-adserver,代码行数:101,代码来源:Priority_getAgencyCampaignsDeliveriesToDate.dal.test.php
示例8: testAuditParentId
function testAuditParentId()
{
// Insert a banner with parents
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->description = 'Banner A';
$bannerId = DataGenerator::generateOne($doBanners, true);
$campaignId = DataGenerator::getReferenceId('campaigns');
// Delete the campaign
$doCampaigns = OA_Dal::staticGetDO('campaigns', $campaignId);
$doCampaigns->delete();
// Test the campaign auditid == banner parentid
$oAuditCampaign = $this->_fetchAuditRecord('campaigns', OA_AUDIT_ACTION_DELETE);
$this->assertNull($oAuditCampaign->parentid);
$oAuditBanner = $this->_fetchAuditRecord('banners', OA_AUDIT_ACTION_DELETE);
$this->assertEqual($oAuditCampaign->auditid, $oAuditBanner->parentid);
DataGenerator::cleanUp(array('accounts', 'campaigns', 'banners', 'audit'));
}
示例9: _createTestData
/**
* Function creates 2 zones on 1 website and 2 campaigns 2 banners each under 1 advertiser
* website and advertiser are under the same agency
*
* @return array Array of DB Ids in format:
* array = ( 'zones' => array ( 0=> zone_id_1, ...),
* 'agency => array ( 0=> agency_id ) ... )
* keys: 'zones', 'affiliates', 'agency', 'clients', 'campaigns', 'images', 'banners', 'trackers', 'channel'
*/
function _createTestData()
{
$aIds = array();
// Create zones and websites
$doZones = OA_Dal::factoryDO('zones');
$doZones->zonename = 'Zone 1';
$doZones->width = 468;
$doZones->height = 60;
$doZones->delivery = phpAds_ZoneBanner;
$aIds['zones'][0] = DataGenerator::generateOne($doZones, true);
$aIds['affiliates'][0] = DataGenerator::getReferenceId('affiliates');
$aIds['agency'][0] = DataGenerator::getReferenceId('agency');
$doZones->zonename = 'Zone 2';
$doZones->affiliateid = $aIds['affiliates'][0];
$aIds['zones'][1] = DataGenerator::generateOne($doZones, true);
$doClients = OA_Dal::factoryDO('clients');
$doClients->clientname = 'Advertiser 1';
$doClients->agencyid = $aIds['agency'][0];
$aIds['clients'][0] = DataGenerator::generateOne($doClients);
// Create campaigns
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = 'Campaign 1';
$doCampaigns->clientid = $aIds['clients'][0];
$aIds['campaigns'][0] = DataGenerator::generateOne($doCampaigns);
$doCampaigns->campaignname = 'Campaign 2';
$aIds['campaigns'][1] = DataGenerator::generateOne($doCampaigns);
// Create images and banners
$doImages = OA_Dal::factoryDO('images');
for ($i = 0; $i < 4; $i++) {
$aIds['images'][$i] = 'test' . $i . '.gif';
$doImages->filename = $aIds['images'][$i];
DataGenerator::generateOne($doImages);
}
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->width = 468;
$doBanners->height = 60;
$doBanners->storagetype = 'sql';
$doBanners->contenttype = 'gif';
$doBanners->name = 'Banner 1-1';
$doBanners->filename = $aIds['images'][0];
$doBanners->campaignid = $aIds['campaigns'][0];
$aIds['banners'][0] = DataGenerator::generateOne($doBanners);
$doBanners->name = 'Banner 1-2';
$doBanners->filename = $aIds['images'][1];
$doBanners->campaignid = $aIds['campaigns'][0];
$aIds['banners'][1] = DataGenerator::generateOne($doBanners);
$doBanners->name = 'Banner 2-1';
$doBanners->filename = $aIds['images'][2];
$doBanners->campaignid = $aIds['campaigns'][1];
$aIds['banners'][2] = DataGenerator::generateOne($doBanners);
$doBanners->name = 'Banner 2-2';
$doBanners->filename = $aIds['images'][3];
$doBanners->campaignid = $aIds['campaigns'][1];
$aIds['banners'][3] = DataGenerator::generateOne($doBanners);
// Create tracker
$doTrackers = OA_Dal::factoryDO('trackers');
$doTrackers->trackername = "Tracker 1";
$doTrackers->clientid = $aIds['clients'][0];
$aIds['trackers'][0] = DataGenerator::generateOne($doTrackers);
// Create Channel
$doChannel = OA_Dal::factoryDO('channel');
$doChannel->agencyid = $aIds['agency'][0];
$doChannel->affiliateid = $aIds['affiliates'][0];
$doChannel->name = 'Website channel';
$aIds['channel'][0] = DataGenerator::generateOne($doChannel);
// link zones (and banners) to campaigns
$dalZones = OA_Dal::factoryDAL('zones');
$dalZones->linkZonesToCampaign($aIds['zones'], $aIds['campaigns'][0]);
$dalZones->linkZonesToCampaign($aIds['zones'], $aIds['campaigns'][1]);
return $aIds;
}
示例10: testGetZoneByKeyword
function testGetZoneByKeyword()
{
// Search for zones when none exist.
$expected = 0;
$rsZones = $this->dalZones->getZoneByKeyword('foo');
$rsZones->find();
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
$agencyId = 1;
$rsZones = $this->dalZones->getZoneByKeyword('foo', $agencyId);
$rsZones->find();
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
$affiliateId = 1;
$rsZones = $this->dalZones->getZoneByKeyword('foo', null, $affiliateId);
$rsZones->find();
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
$affiliateId = 1;
$rsZones = $this->dalZones->getZoneByKeyword('foo', $agencyId, $affiliateId);
$rsZones->find();
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
// Add a zone (and parent objects)
$doZones = OA_Dal::factoryDO('zones');
$doZones->zonename = 'foo';
$doZones->description = 'bar';
$zoneId = DataGenerator::generateOne($doZones, true);
$affiliateId1 = DataGenerator::getReferenceId('affiliates');
$agencyId1 = DataGenerator::getReferenceId('agency');
// Add another zone
$doZones = OA_Dal::factoryDO('zones');
$doZones->zonename = 'baz';
$doZones->description = 'quux';
$zoneId = DataGenerator::generateOne($doZones, true);
$agencyId2 = DataGenerator::getReferenceId('agency');
// Search for the zone by string
$expected = 1;
$rsZones = $this->dalZones->getZoneByKeyword('foo');
$rsZones->find();
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
$rsZones = $this->dalZones->getZoneByKeyword('bar');
$rsZones->find();
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
// Restrict the search to agency ID
$expected = 0;
$rsZones = $this->dalZones->getZoneByKeyword('foo', $agencyId = 0);
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
$expected = 1;
$rsZones = $this->dalZones->getZoneByKeyword('foo', $agencyId1);
$rsZones->find();
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
// Restrict the search to affiliate ID
$expected = 0;
$rsZones = $this->dalZones->getZoneByKeyword('foo', $agencyId, $affiliateId = 0);
$rsZones->find();
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
$expected = 1;
$rsZones = $this->dalZones->getZoneByKeyword('foo', $agencyId1, $affiliateId1);
$rsZones->find();
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
$rsZones = $this->dalZones->getZoneByKeyword('bar', null, $affiliateId1);
$rsZones->find();
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
// Search for zone by zone ID
$expected = 1;
$rsZones = $this->dalZones->getZoneByKeyword($zoneId);
$rsZones->find();
$actual = $rsZones->getRowCount();
$this->assertEqual($actual, $expected);
}
示例11: _generateData
public function _generateData($priority)
{
$oDbh =& OA_DB::singleton();
// Create the required temporary table for the tests
$oTable =& OA_DB_Table_Priority::singleton();
$oTable->createTable('tmp_ad_zone_impression');
// set up agencies, affiliates and zones
$idClient1 = DataGenerator::generateOne('clients', true);
$agencyId1 = DataGenerator::getReferenceId('agency');
$idClient2 = DataGenerator::generateOne('clients', true);
$agencyId2 = DataGenerator::getReferenceId('agency');
$idClient3 = DataGenerator::generateOne('clients', true);
$agencyId3 = DataGenerator::getReferenceId('agency');
// Add affiliates (websites)
$doAffiliates = OA_Dal::factoryDO('affiliates');
$doAffiliates->agencyid = $agencyId1;
$affiliateId1 = DataGenerator::generateOne($doAffiliates);
$doAffiliates = OA_Dal::factoryDO('affiliates');
$doAffiliates->agencyid = $agencyId3;
$affiliateId2 = DataGenerator::generateOne($doAffiliates);
$doZones = OA_Dal::factoryDO('zones');
$doZones->description = 'Test zone';
$doZones->affiliateid = $affiliateId1;
$this->idZone1 = DataGenerator::generateOne($doZones);
$doZones = OA_Dal::factoryDO('zones');
$doZones->description = 'Test zone';
$doZones->affiliateid = $affiliateId2;
$idZone2 = DataGenerator::generateOne($doZones);
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->clientid = $idClient1;
$doCampaigns->priority = --$priority;
$doCampaigns->ecpm_enabled = 1;
$idCampaign1 = DataGenerator::generateOne($doCampaigns);
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->campaignid = $idCampaign1;
$idAd1 = DataGenerator::generateOne($doBanners);
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->clientid = $idClient1;
$doCampaigns->priority = ++$priority;
$doCampaigns->ecpm_enabled = 1;
$idCampaign2 = DataGenerator::generateOne($doCampaigns);
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->campaignid = $idCampaign2;
$idAd2 = DataGenerator::generateOne($doBanners);
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->clientid = $idClient1;
$doCampaigns->priority = ++$priority;
$doCampaigns->ecpm_enabled = 1;
$idCampaign3 = DataGenerator::generateOne($doCampaigns);
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->campaignid = $idCampaign3;
$idAd3 = DataGenerator::generateOne($doBanners);
$query = "\n INSERT INTO\n tmp_ad_zone_impression\n (\n ad_id,\n zone_id,\n required_impressions,\n requested_impressions,\n to_be_delivered\n )\n VALUES\n (\n 1,\n {$idZone2},\n 2,\n 3,\n 1\n )";
$rows = $oDbh->exec($query);
$query = "\n INSERT INTO\n tmp_ad_zone_impression\n (\n ad_id,\n zone_id,\n required_impressions,\n requested_impressions,\n to_be_delivered\n )\n VALUES\n (\n {$idAd1},\n {$this->idZone1},\n 1,\n 5,\n 1\n )";
$rows = $oDbh->exec($query);
$query = "\n INSERT INTO\n tmp_ad_zone_impression\n (\n ad_id,\n zone_id,\n required_impressions,\n requested_impressions,\n to_be_delivered\n )\n VALUES\n (\n {$idAd2},\n {$this->idZone1},\n 2,\n 5,\n 1\n )";
$rows = $oDbh->exec($query);
$query = "\n INSERT INTO\n tmp_ad_zone_impression\n (\n ad_id,\n zone_id,\n required_impressions,\n requested_impressions,\n to_be_delivered\n )\n VALUES\n (\n {$idAd3},\n {$this->idZone1},\n 5,\n 5,\n 1\n )";
$rows = $oDbh->exec($query);
$query = "\n INSERT INTO\n tmp_ad_zone_impression\n (\n ad_id,\n zone_id,\n required_impressions,\n requested_impressions,\n to_be_delivered\n )\n VALUES\n (\n 2,\n {$this->idZone1},\n 6,\n 7,\n 0\n )";
$rows = $oDbh->exec($query);
return array($agencyId1, $agencyId2);
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:64,代码来源:Priority_getZonesAllocationsByAgency.dal.test.php