本文整理汇总了PHP中Mock::generatePartial方法的典型用法代码示例。如果您正苦于以下问题:PHP Mock::generatePartial方法的具体用法?PHP Mock::generatePartial怎么用?PHP Mock::generatePartial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mock
的用法示例。
在下文中一共展示了Mock::generatePartial方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_executeTasksTablesAlter
function test_executeTasksTablesAlter()
{
$this->assertTrue($this->initDatabase(325, array('campaigns')) . 'failed to created version 325 of campaigns table');
$tblCampaigns = $this->oDbh->quoteIdentifier($this->prefix . 'campaigns', true);
// Insert some data to test the upgrade from... we know the schema being used so we can directly insert
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (1,'campaign one', 1, 100, 10, 1, '2000-01-01', '2000-01-01', 't', 'h', 1, 1, 'f', 'f')");
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (2,'campaign two', 1, 100, 10, 1, '2000-01-01', '2000-01-01', 't', 'm', 1, 1, 'f', 'f')");
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (3,'campaign three', 1, -1, -1, -1, '2000-01-01', '2000-01-01', 't', 'l', 1, 1, 'f', 'f')");
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (4,'campaign four', 1, 100, 10, 1, '2000-01-01', '2000-01-01', 't', 'h', 1, 1, 'f', 'f')");
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (5,'campaign five', 1, 100, 10, 1, '2000-01-01', '2000-01-01', 't', 'm', 1, 1, 'f', 'f')");
$this->oDbh->exec("INSERT INTO {$tblCampaigns} VALUES (6,'campaign six', 1, -1, -1, -1, '2000-01-01', '2000-01-01', 't', 'l', 1, 1, 'f', 'f')");
Mock::generatePartial('OA_DB_UpgradeAuditor', $mockAuditor = 'OA_DB_UpgradeAuditor' . rand(), array('logAuditAction', 'setKeyParams'));
$oLogger = new OA_UpgradeLogger();
$oLogger->setLogFile('DB_Upgrade.test.log');
$oDB_Upgrade = new OA_DB_Upgrade($oLogger);
$oDB_Upgrade->oAuditor = new $mockAuditor($this);
$oDB_Upgrade->oAuditor->setReturnValue('logAuditAction', true);
$oDB_Upgrade->oAuditor->setReturnValue('setKeyParams', true);
$oDB_Upgrade->init('constructive', 'tables_core', 326);
$aDef325 = $this->oaTable->aDefinition;
$oDB_Upgrade->aDBTables = $oDB_Upgrade->_listTables();
$this->assertTrue($oDB_Upgrade->_verifyTasksTablesAlter(), 'failed _verifyTasksTablesAlter: change field');
$this->assertTrue($oDB_Upgrade->_executeTasksTablesAlter(), 'failed _executeTasksTablesAlter: change field');
$aDefDB = $oDB_Upgrade->oSchema->getDefinitionFromDatabase(array($this->prefix . 'campaigns'));
$aDiff = $oDB_Upgrade->oSchema->compareDefinitions($this->aDefNew, $aDefDb);
$this->assertEqual(count($aDiff), 0, 'comparison failed');
$aResults = $this->oDbh->queryAll("SELECT * FROM " . $tblCampaigns);
$this->assertIsa($aResults, 'array');
$expected = array(1 => '5', 2 => '3', 3 => '0', 4 => '5', 5 => '3', 6 => '0');
foreach ($aResults as $idx => $aRow) {
$this->assertEqual($aRow['priority'], $expected[$aRow['campaignid']], ' unexpected campaign priority value detected after upgrade');
}
}
示例2: Test_OA_Maintenance_Priority_AdServer_Task_ECPMforRemnant
/**
* The constructor method.
*/
function Test_OA_Maintenance_Priority_AdServer_Task_ECPMforRemnant()
{
$this->UnitTestCase();
Mock::generate('OA_Dal_Maintenance_Priority', $this->mockDal = 'MockOA_Dal_Maintenance_Priority' . rand());
Mock::generate('MAX_Dal_Admin_Data_intermediate_ad', $this->mockDalIntermediateAd = 'MAX_Dal_Admin_Data_intermediate_ad' . rand());
Mock::generatePartial('OA_Maintenance_Priority_AdServer_Task_ECPMforRemnant', 'PartialMock_OA_Maintenance_Priority_AdServer_Task_ECPMforRemnant', array('_getDal', '_factoryDal', 'getTodaysRemainingOperationIntervals', 'calculateCampaignEcpm'));
}
示例3: Test_OX_Maintenance_Priority_Campaign
/**
* The class constructor method.
*/
function Test_OX_Maintenance_Priority_Campaign()
{
$this->UnitTestCase();
Mock::generate('MAX_Dal_Entities');
Mock::generate('OA_Dal_Maintenance_Priority');
Mock::generatePartial('OX_Maintenance_Priority_Campaign', 'MockPartialOX_Maintenance_Priority_Campaign', array('_abort'));
}
示例4: testgetTasksUrls
function testgetTasksUrls()
{
// Mock install status to mark update process
Mock::generatePartial('OX_Admin_UI_Install_InstallStatus', 'OX_Admin_UI_Install_InstallStatusMock', array('isUpgrade'));
$oInstallStatus = new OX_Admin_UI_Install_InstallStatusMock($this);
$oInstallStatus->setReturnValue('isUpgrade', true);
$oStorage = OX_Admin_UI_Install_InstallUtils::getSessionStorage();
@($oStatus = $oStorage->set('installStatus', $oInstallStatus));
include MAX_PATH . '/etc/default_plugins.php';
// set default plugins as installed except last one
foreach ($aDefaultPlugins as $idx => $aPlugin) {
$GLOBALS['_MAX']['CONF']['plugins'][$aPlugin['name']] = true;
$lastPlugin = $aPlugin['name'];
$lastPluginData = $aPlugin;
}
unset($GLOBALS['_MAX']['CONF']['plugins'][$lastPlugin]);
$baseInstallUrl = 'my base url';
$GLOBALS['strPluginTaskChecking'] = 'Checking';
$GLOBALS['strPluginTaskInstalling'] = 'Installing';
$aExpected = array();
foreach ($GLOBALS['_MAX']['CONF']['plugins'] as $pluginName => $pluginEnabled) {
$aExpected[] = array('id' => 'plugin:' . $pluginName, 'name' => $GLOBALS['strPluginTaskChecking'] . ': <br/> ' . $this->_correctPluginName($pluginName), 'url' => $baseInstallUrl . 'install-plugin.php?status=1&plugin=' . $pluginName);
}
$aExpected[] = array('id' => 'plugin:' . $lastPlugin, 'name' => $GLOBALS['strPluginTaskInstalling'] . ': <br/> ' . $this->_correctPluginName($lastPlugin), 'url' => $baseInstallUrl . 'install-plugin.php?status=0&plugin=' . $lastPlugin . (empty($lastPluginData['disabled']) ? '' : '&disabled=1'));
$result = OX_Upgrade_InstallPlugin_Controller::getTasksUrls($baseInstallUrl);
$this->assertEqual($result, $aExpected);
$oStatus = $oStorage->set('installStatus', null);
}
示例5: __construct
/**
* The class constructor method.
*/
function __construct()
{
parent::__construct();
Mock::generate('MAX_Dal_Entities');
Mock::generate('OA_Dal_Maintenance_Priority');
Mock::generatePartial('OX_Maintenance_Priority_Campaign', 'MockPartialOX_Maintenance_Priority_Campaign', array('_abort'));
}
示例6: __construct
/**
* The constructor method.
*/
function __construct()
{
parent::__construct();
Mock::generatePartial('OA_Dll_Agency', 'PartialMockOA_Dll_Agency_AdvertiserTest', array('checkPermissions'));
parent::__construct();
Mock::generatePartial('OA_Dll_Advertiser', 'PartialMockOA_Dll_Advertiser_AdvertiserTest', array('checkPermissions', 'getDefaultAgencyId'));
}
示例7: OA_Dll_AdvertiserTest
/**
* The constructor method.
*/
function OA_Dll_AdvertiserTest()
{
$this->UnitTestCase();
Mock::generatePartial('OA_Dll_Agency', 'PartialMockOA_Dll_Agency_AdvertiserTest', array('checkPermissions'));
$this->UnitTestCase();
Mock::generatePartial('OA_Dll_Advertiser', 'PartialMockOA_Dll_Advertiser_AdvertiserTest', array('checkPermissions', 'getDefaultAgencyId'));
}
示例8: testExecute
function testExecute()
{
Mock::generatePartial('OA_UpgradeLogger', $mockLogger = 'OA_UpgradeLogger' . rand(), array('logOnly', 'logError', 'log'));
$oLogger = new $mockLogger($this);
$oLogger->setReturnValue('logOnly', true);
$oLogger->setReturnValue('logError', true);
$oLogger->setReturnValue('log', true);
Mock::generatePartial('OA_Upgrade', $mockUpgrade = 'OA_Upgrade' . rand(), array('addPostUpgradeTask'));
$mockUpgrade = new $mockUpgrade($this);
$mockUpgrade->setReturnValue('addPostUpgradeTask', true);
$mockUpgrade->oLogger = $oLogger;
$mockUpgrade->oDBUpgrader = new OA_DB_Upgrade($oLogger);
$mockUpgrade->oDBUpgrader->oTable =& $this->oaTable;
// Run the upgrade
$postscript = new OA_UpgradePostscript_2_7_30_beta_rc5();
$ret = $postscript->execute(array(&$mockUpgrade));
$this->assertTrue($ret);
// Get the preference that we have inserted
$doPreferences = OA_Dal::factoryDO('preferences');
$doPreferences->preference_name = 'campaign_ecpm_enabled';
$doPreferences->account_type = 'MANAGER';
$doPreferences->find();
$numberPreferences = $doPreferences->getRowCount();
$this->assertEqual(1, $numberPreferences);
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:25,代码来源:postscript_openads_upgrade_2.7.30-beta-rc5.mig.test.php
示例9: __construct
/**
* The constructor method.
*/
function __construct()
{
parent::__construct();
Mock::generate('OA_Dal_Maintenance_Priority', $this->mockDal = 'MockOA_Dal_Maintenance_Priority' . rand());
Mock::generatePartial('OA_Maintenance_Priority_AdServer_Task_PriorityCompensation', 'PartialMock_OA_Maintenance_Priority_AdServer_Task_PriorityCompensation', array('_getDal', '_getOperationIntUtils', '_getMaxEntityAdObject'));
Mock::generatePartial('OA_Maintenance_Priority_Ad', 'PartialOA_Maintenance_Priority_Ad', array());
}
示例10: testDuplicate
function testDuplicate()
{
$GLOBALS['strCopyOf'] = 'Copy of ';
$filename = 'test.gif';
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->filename = $filename;
$doBanners->storagetype = 'sql';
$doBanners->acls_updated = '2007-04-03 19:28:06';
$id1 = DataGenerator::generateOne($doBanners, true);
$doBanners = OA_Dal::staticGetDO('banners', $id1);
Mock::generatePartial('DataObjects_Banners', $mockBanners = 'DataObjects_Banners' . rand(), array('_imageDuplicate'));
$doMockBanners = new $mockBanners($this);
$doMockBanners->init();
$doMockBanners->setFrom($doBanners);
$doMockBanners->bannerid = $doBanners->bannerid;
// setFrom() doesn't copy primary key
$doMockBanners->setReturnValue('_imageDuplicate', $filename);
// make sure image was duplicated as well
$doMockBanners->expectOnce('_imageDuplicate');
$id2 = $doMockBanners->duplicate();
// duplicate
$doMockBanners->tally();
$this->assertNotEmpty($id2);
$this->assertNotEqual($id1, $id2);
$doBanners1 = OA_Dal::staticGetDO('banners', $id1);
$doBanners2 = OA_Dal::staticGetDO('banners', $id2);
// assert they are equal (but without comparing primary key)
$this->assertNotEqualDataObjects($this->stripKeys($doBanners1), $this->stripKeys($doBanners2));
// Test that the only difference is their description
$doBanners1->description = $doBanners2->description = null;
$this->assertEqualDataObjects($this->stripKeys($doBanners1), $this->stripKeys($doBanners2));
}
示例11: getPluginPackageManager
static function getPluginPackageManager($mock)
{
if ($mock) {
Mock::generatePartial('OX_PluginManager', $mockPkgMgrClass = 'MOX_PluginManager' . rand(), array('_auditInit', '_auditSetKeys', '_auditStart', '_auditUpdate', '_auditSetID', '_checkDatabaseEnvironment', '_registerSchema', '_registerPreferences', '_registerPluginVersion', '_unregisterSchema', '_unregisterPreferences', '_unregisterPluginVersion', '_runExtensionTasks'));
$oPkgMgr = new $mockPkgMgrClass();
// install tasks
$oPkgMgr->setReturnValue('_auditInit', true);
$oPkgMgr->setReturnValue('_auditSetKeys', true);
$oPkgMgr->setReturnValue('_auditStart', true);
$oPkgMgr->setReturnValue('_auditUpdate', true);
$oPkgMgr->setReturnValue('_checkDatabaseEnvironment', true);
//$oPkgMgr->setReturnValue('_runScript', true);
//$oPkgMgr->setReturnValue('_checkDependenciesForInstallOrEnable', true);
//$oPkgMgr->setReturnValue('_checkFiles', true);
//$oPkgMgr->setReturnValue('_checkMenus', true);
$oPkgMgr->setReturnValue('_registerSchema', true);
$oPkgMgr->setReturnValue('_registerPreferences', true);
//$oPkgMgr->setReturnValue('_registerSettings', true);
$oPkgMgr->setReturnValue('_registerPluginVersion', true);
// uninstall tasks
//$oPkgMgr->setReturnValue('_checkDependenciesForUninstallOrDisable', true);
$oPkgMgr->setReturnValue('_unregisterPluginVersion', true);
$oPkgMgr->setReturnValue('_unregisterPreferences', true);
//$oPkgMgr->setReturnValue('_unregisterSettings', true);
$oPkgMgr->setReturnValue('_unregisterSchema', true);
//$oPkgMgr->setReturnValue('_removeFiles', true);
} else {
$oPkgMgr = new OX_PluginManager();
}
$oPkgMgr->init();
return $oPkgMgr;
}
示例12: testdllValidation
function testdllValidation()
{
Mock::generatePartial('OA_Dll_User', 'PartialMockOA_Dll_User', array('raiseError'));
$dllUserMock = new PartialMockOA_Dll_User();
$dllUserMock->setReturnValue('raiseError', true);
$dllUserMock->expectCallCount('raiseError', 2);
$oUserInfo = new OA_Dll_UserInfo();
// Test with nothing set
$this->assertFalse($this->oPlugin->dllValidation($dllUserMock, $oUserInfo));
// Test with username set
$oUserInfo->username = 'foobar';
$this->assertFalse($this->oPlugin->dllValidation($dllUserMock, $oUserInfo));
// Test with username and password set
$oUserInfo->password = 'pwd';
$this->assertTrue($this->oPlugin->dllValidation($dllUserMock, $oUserInfo));
$this->assertEqual($oUserInfo->password, md5('pwd'));
// Test edit
$oUserInfo = new OA_Dll_UserInfo();
$oUserInfo->userId = 1;
$this->assertTrue($this->oPlugin->dllValidation($dllUserMock, $oUserInfo));
$this->assertNull($oUserInfo->password);
// Test edit with new password
$oUserInfo->password = 'pwd';
$this->assertTrue($this->oPlugin->dllValidation($dllUserMock, $oUserInfo));
$this->assertEqual($oUserInfo->password, md5('pwd'));
$dllUserMock->tally();
}
示例13: test_dependencies_api
/**
* Test dependencies.
*/
function test_dependencies_api()
{
global $app_version;
Mock::generatePartial('Plugin', 'PluginTestVersion', array('GetDependencies'));
// Only major version given (not fulfilled)
$test_Plugin = new PluginTestVersion();
$test_Plugin->setReturnValue('GetDependencies', array('requires' => array('app_min' => '1000')));
$dep_msgs = $this->Plugins->validate_dependencies($test_Plugin, 'enable');
$this->assertEqual(array_keys($dep_msgs), array('error'));
$this->assertEqual(count($dep_msgs['error']), 1);
// Current version given (fulfilled)
$test_Plugin = new PluginTestVersion();
$test_Plugin->setReturnValue('GetDependencies', array('requires' => array('app_min' => $app_version)));
$dep_msgs = $this->Plugins->validate_dependencies($test_Plugin, 'enable');
$this->assertEqual(array_keys($dep_msgs), array());
// Only major version given (fulfilled)
$test_Plugin = new PluginTestVersion();
$test_Plugin->setReturnValue('GetDependencies', array('requires' => array('app_min' => '0')));
$dep_msgs = $this->Plugins->validate_dependencies($test_Plugin, 'enable');
$this->assertEqual(array_keys($dep_msgs), array());
// Obsolete "api_min" (fulfilled)
$test_Plugin = new PluginTestVersion();
$test_Plugin->setReturnValue('GetDependencies', array('requires' => array('api_min' => array(1, 1))));
$dep_msgs = $this->Plugins->validate_dependencies($test_Plugin, 'enable');
$this->assertEqual(array_keys($dep_msgs), array());
}
示例14: Test_OA_DB_Table
/**
* The constructor method.
*/
function Test_OA_DB_Table()
{
$this->UnitTestCase();
// Mock the OA_DB class
Mock::generate('OA_DB');
// Partially mock the OA_DB_Table class
Mock::generatePartial('OA_DB_Table', 'PartialMockOA_DB_Table', array('_getDbConnection'));
}
示例15: __construct
/**
* The constructor method.
*/
function __construct()
{
parent::__construct();
// Mock the OA_DB class
Mock::generate('OA_DB');
// Partially mock the OA_DB_Table class
Mock::generatePartial('OA_DB_Table', 'PartialMockOA_DB_Table', array('_getDbConnection'));
}