当前位置: 首页>>代码示例>>PHP>>正文


PHP DataGenerator::setData方法代码示例

本文整理汇总了PHP中DataGenerator::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP DataGenerator::setData方法的具体用法?PHP DataGenerator::setData怎么用?PHP DataGenerator::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataGenerator的用法示例。


在下文中一共展示了DataGenerator::setData方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DataGenerator

 function test_genericHtml_class()
 {
     // test the class implementation
     $oComponent =& OX_Component::factory('bannerTypeHtml', 'demoBannerTypeHtml', 'demoHtml');
     // common extension methods
     $this->_assertClass($oComponent, 'bannerTypeHtml', 'demoBannerTypeHtml', 'demoHtml');
     // plugin-specific methods
     $this->assertTrue(method_exists($oComponent, '_buildHtmlTemplate'), $sender . ' missing method _buildHtmlTemplate');
     $this->assertTrue(method_exists($oComponent, 'exportData'), $sender . ' missing method exportData');
     // generate test data
     $doBanners = OA_Dal::factoryDO('banners');
     $oDG = new DataGenerator();
     $oDG->setData('banners', array('ext_bannertype' => array($oComponent->getComponentIdentifier())));
     $aIds = $oDG->generate($doBanners, 5, false);
     $aFields = $aVariables = array();
     // test the processForm method
     // this method joins the banners and banners_demo tables
     // by creating a banners_demo record where
     // banners_demo.banners_demo_id = banners.bannerid
     foreach ($aIds as $i => $bannerId) {
         $aFields['description'] = 'description_' . $bannerId;
         $this->assertTrue($oComponent->processForm(true, $bannerId, $aFields, $aVariables));
         $doBannersDemo = OA_Dal::factoryDO('banners_demo');
         $doBannersDemo->banners_demo_id = $bannerId;
         $this->assertTrue($doBannersDemo->find(true));
         $this->assertEqual($doBannersDemo->banners_demo_desc, $aFields['description']);
     }
     // test the exportData method
     $aTables = $oComponent->exportData();
     $this->assertIsA($aTables, 'array');
     $this->assertEqual(count($aTables), 2);
     $prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
     $pattern = '/' . $prefix . 'z_' . $oComponent->component . '[\\d]{8}_[\\d]{6}' . $prefix . 'banners/';
     $this->assertPattern($pattern, $aTables[0]);
     $pattern = '/' . $prefix . 'z_' . $oComponent->component . '[\\d]{8}_[\\d]{6}' . $prefix . 'banners_demo/';
     $this->assertPattern($pattern, $aTables[1]);
     $oDbh = OA_DB::singleton();
     $query = "SELECT * FROM " . $oDbh->quoteIdentifier($aTables[0]);
     $aResult = $oDbh->queryAll($query, null, MDB2_FETCHMODE_ASSOC);
     foreach ($aResult as $i => $aFrom) {
         $this->assertEqual($aFrom['bannerid'], $aIds[$i]);
     }
     $query = "SELECT * FROM " . $oDbh->quoteIdentifier($aTables[1]);
     $aResult = $oDbh->queryAll($query, null, MDB2_FETCHMODE_ASSOC);
     foreach ($aResult as $i => $aFrom) {
         $this->assertEqual($aFrom['banners_demo_id'], $aIds[$i]);
     }
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:48,代码来源:demoBannerTypeHtml.plg.test.php

示例2: testBelongsToAccount

 function testBelongsToAccount()
 {
     OA_Dal::factoryDO('banners');
     // Initialise the class so it can be mocked.
     Mock::generatePartial('DataObjects_Banners', $mockBanners = 'DataObjects_Banners' . rand(), array('getOwningAccountIds'));
     $doMockBanners = new $mockBanners($this);
     $doMockBanners->init();
     $clientId = DataGenerator::generateOne('clients', true);
     $doClients = OA_Dal::staticGetDO('clients', $clientId);
     $agencyId = $doClients->agencyid;
     $accountId = $doClients->account_id;
     $doAgency = OA_Dal::staticGetDO('agency', $agencyId);
     $managerId = $doAgency->account_id;
     $dg = new DataGenerator();
     $dg->setData('campaigns', array('clientid' => array($clientId)));
     $doMockBanners->setReturnValue('getOwningAccountIds', array(OA_ACCOUNT_MANAGER => $managerId, OA_ACCOUNT_ADVERTISER => $accountId));
     $this->enableAuditing(true);
     $bannerId = $dg->generateOne($doMockBanners, true);
     $this->enableAuditing(false);
     $doAudit = OA_Dal::factoryDO('audit');
     $doAudit->context = 'banners';
     $doAudit->contextid = $bannerId;
     $this->assertTrue($doAudit->find(true));
     $this->assertTrue($doAudit->belongsToAccount($accountId, false));
     // generate different audit on campaign
     $dg = new DataGenerator();
     $doMockBanners = new $mockBanners($this);
     $doMockBanners->init();
     $clientId2 = DataGenerator::generateOne('clients', true);
     $doClients = OA_Dal::staticGetDO('clients', $clientId2);
     $agencyId2 = $doClients->agencyid;
     $accountId2 = $doClients->account_id;
     $doAgency = OA_Dal::staticGetDO('agency', $agencyId2);
     $managerId2 = $doAgency->account_id;
     $dg->setData('campaigns', array('clientid' => array($clientId2)));
     $doMockBanners->setReturnValue('getOwningAccountIds', array(OA_ACCOUNT_MANAGER => $managerId2, OA_ACCOUNT_ADVERTISER => $accountId2));
     $this->enableAuditing(true);
     $bannerId2 = $dg->generateOne($doMockBanners, true);
     $this->enableAuditing(false);
     $doAudit = OA_Dal::factoryDO('audit');
     $doAudit->context = 'banners';
     $doAudit->contextid = $bannerId2;
     $this->assertTrue($doAudit->find(true));
     $this->assertTrue($doAudit->belongsToAccount($accountId2, false));
     $this->assertFalse($doAudit->belongsToAccount($accountId, false));
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:46,代码来源:Audit.dal.test.php

示例3: testGetChannelsAndAffiliates

 function testGetChannelsAndAffiliates()
 {
     // Insert 2 channels
     $aData = array('acls_updated' => array('2007-04-04 17:27:33'));
     $dg = new DataGenerator();
     $dg->setData('channel', $aData);
     $aChannelId = $dg->generate('channel', 2, true);
     // Check the correct number of rows returned
     $expectedRows = 2;
     $rsChannel = $this->dalChannel->getChannelsAndAffiliates();
     $rsChannel->find();
     $actualRows = $rsChannel->getRowCount();
     $this->assertEqual($actualRows, $expectedRows);
     // Check each row has the correct number of fields
     $rsChannel->fetch();
     $aChannel = $rsChannel->export();
     $this->assertEqual(count($aChannel), 4);
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:18,代码来源:Channel.dal.test.php

示例4: testDeleteWhereOne

 function testDeleteWhereOne()
 {
     $this->oaTable->createTable('audit');
     $this->oaTable->createTable('acls');
     $dg = new DataGenerator();
     $dg->setData('acls', array('bannerid' => array(1, 2, 3), 'executionorder' => array(0, 0, 0, 1, 1, 1, 2, 2, 2)));
     $dg->generate('acls', 5);
     OA_DB_Sql::deleteWhereOne('acls', 'bannerid', 1);
     $doAcls = OA_Dal::factoryDO('acls');
     $doAcls->bannerid = 1;
     $doAcls->find();
     $this->assertEqual(0, $doAcls->getRowCount());
     $doAcls->bannerid = 2;
     $doAcls->find();
     $this->assertEqual(2, $doAcls->getRowCount());
     $aConf = $GLOBALS['_MAX']['CONF'];
     $this->oaTable->dropTable($aConf['table']['prefix'] . 'acls');
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:18,代码来源:Sql.tbl.test.php

示例5: testGetAclsByDataValueType

 function testGetAclsByDataValueType()
 {
     $type = 'Site:Channel';
     $bannerId = 1;
     $channelId = 1;
     // Test it returns empty set if no data exists
     $rsChannel = $this->dalAcls->getAclsByDataValueType($bannerId, $type);
     $rsChannel->reset();
     $this->assertEqual($rsChannel->getRowCount(), 0);
     // Generate acls, two of them with the same $bannerId
     $data = array('bannerid' => array($bannerId, $bannerId, 3), 'data' => array("{$channelId},2,3", '4,5,6', "{$channelId}"), 'executionorder' => array(1, 2, 3));
     $dg = new DataGenerator();
     $dg->setData('acls', $data);
     // Add test data
     $doAcls = OA_Dal::factoryDO('acls');
     $doAcls->type = $type;
     $dg->generate($doAcls, 3, true);
     // Test that $bannerId is in two sets
     $rsChannel = $this->dalAcls->getAclsByDataValueType($channelId, $type);
     $rsChannel->reset();
     $this->assertEqual($rsChannel->getRowCount(), 2);
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:22,代码来源:Acls.dal.test.php

示例6: 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);
 }
开发者ID:Jaree,项目名称:revive-adserver,代码行数:34,代码来源:Campaigns.dal.test.php

示例7: testGetBannersCampaignsClients

 function testGetBannersCampaignsClients()
 {
     // Insert 2 banners
     $doBanners = OA_Dal::factoryDO('banners');
     $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);
     $aBannerIds = $dg->generate($doBanners, 2, true);
     // Check the correct number of rows returned
     $expectedRows = 2;
     $rsBanners = $this->dalBanners->getBannersCampaignsClients();
     $rsBanners->find();
     $actualRows = $rsBanners->getRowCount();
     $this->assertEqual($actualRows, $expectedRows);
     // Check each row has the correct number of fields
     $rsBanners->fetch();
     $aBanner = $rsBanners->export();
     $this->assertEqual(count($aBanner), 6);
 }
开发者ID:hostinger,项目名称:revive-adserver,代码行数:20,代码来源:Banners.dal.test.php

示例8: 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));
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:34,代码来源:Permission.dal.test.php

示例9: testGetUniqueValuesFromColumn

 function testGetUniqueValuesFromColumn()
 {
     $data = array('name' => array(1, 1, 2, 2, 3));
     $dg = new DataGenerator();
     $dg->setData('agency', $data);
     $dg->generate('agency', 5);
     // Test that it takes 3 unique variables
     $doAgency = OA_Dal::factoryDO('agency');
     $aUnique = $doAgency->getUniqueValuesFromColumn('name');
     sort($aUnique);
     $this->assertEqual($aUnique, array(1, 2, 3));
     $doAgency = OA_Dal::factoryDO('agency');
     $aUnique = $doAgency->getUniqueValuesFromColumn('name', $exceptValue = 2);
     sort($aUnique);
     $this->assertEqual(array_values($aUnique), array(1, 3));
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:16,代码来源:DB_DataObjectCommon.dal.test.php


注:本文中的DataGenerator::setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。