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


PHP DataGenerator类代码示例

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


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

示例1: data

 public function data()
 {
     if ($this->method !== "POST") {
         return array("error" => "Sorry, this endpoint only accepts POST requests. Please see the help documentation.");
     }
     // validate the incoming JSON data to ensure its valid
     $error = Utils::validateJSON($this->rawRequest);
     if ($error) {
         return array("error" => ErrorCodes::API_INVALID_JSON, "error_details" => $error);
     }
     $json = @json_decode($this->rawRequest);
     // validate the JSON contains the appropriate settings for the Code
     $errors = $this->validateCoreSettings($json);
     if ($errors) {
         return $errors;
     }
     $errors = $this->validateDataTypeSettings($json);
     if ($errors) {
         return $errors;
     }
     $errors = $this->validateExportTypeSettings($json);
     if ($errors) {
         return $errors;
     }
     // okay! Now we generate whatever data was requested
     $gen = new DataGenerator(Constants::GEN_ENVIRONMENT_API, $json);
     $response = $gen->generate();
     if ($response["success"]) {
         return $response;
     }
 }
开发者ID:JaeHoYun,项目名称:generatedata,代码行数:31,代码来源:API.class.php

示例2: test_genericHtml_class

 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

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

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

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

示例6: 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;
 }
开发者ID:akirsch,项目名称:revive-adserver,代码行数:27,代码来源:Common.api.php

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

示例8: 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

示例9: 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]));
         }
     }
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:57,代码来源:Channel.dal.test.php

示例10: 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

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

示例12: 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

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

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

示例15: 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]);
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:50,代码来源:Regenerate.mtc.test.php


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