• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Mock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_calling_method_with_no_parameters

 public function test_calling_method_with_no_parameters()
 {
     $mock = new Mock('Test');
     $mock->expects('method')->returns("returned data");
     $this->assertEquals("returned data", $mock->method());
     $this->assertTrue(Mock::verifyAll());
 }
开发者ID:trilopin,项目名称:pt_mock,代码行数:7,代码来源:MockTest.php


示例2: testDisableAll

 /**
  * Tests disableAll().
  *
  * @test
  */
 public function testDisableAll()
 {
     $mock2 = new Mock(__NAMESPACE__, "min", "max");
     $mock2->enable();
     Mock::disableAll();
     $this->assertNotEquals(1234, time());
     $this->assertEquals(1, min([1, 2]));
 }
开发者ID:php-mock,项目名称:php-mock,代码行数:13,代码来源:MockTest.php


示例3: checkNotInstanceof

function checkNotInstanceof()
{
    $a = new Mock();
    $info = array('test');
    for ($i = 0; $i < LOOP; $i++) {
        if (!$a instanceof Mock) {
            $a->doIt($info);
        }
    }
}
开发者ID:jasny,项目名称:Q,代码行数:10,代码来源:stub.php


示例4: 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;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:32,代码来源:TestEnv.php


示例5: setUp

 /**
  * Constructor.
  *
  * @access  public
  * @return  void
  */
 public function setUp()
 {
     parent::setUp();
     Mock::generate('Crumbly_model', get_class($this) . '_mock_model');
     $this->_model = $this->_get_mock('model');
     $this->_subject = new Crumbly_upd();
 }
开发者ID:realfluid,项目名称:umbaugh,代码行数:13,代码来源:test.upd_crumbly.php


示例6: setUp

 function setUp()
 {
     global $DB;
     Mock::generate(get_class($DB), 'mockDB');
     $this->realDB = $DB;
     $DB = new mockDB();
 }
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:7,代码来源:testcourselib.php


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


示例8: __construct

 public function __construct()
 {
     parent::__construct();
     // Make sure the moded db class is available
     Mock::generate('MY_DB');
     Template::$ignore_session = true;
 }
开发者ID:ivantcholakov,项目名称:Bonfire,代码行数:7,代码来源:activity_model_test.php


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


示例10: 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());
 }
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:29,代码来源:plugins.class.simpletest.php


示例11: __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'));
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:10,代码来源:Advertiser.dll.test.php


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


示例13: __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());
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:10,代码来源:PriorityCompensation.mtp.test.php


示例14: Test_OA_Maintenance_Priority_AdServer_Task_AllocateZoneImpressions

 /**
  * The constructor method.
  */
 function Test_OA_Maintenance_Priority_AdServer_Task_AllocateZoneImpressions()
 {
     $this->UnitTestCase();
     Mock::generate('MAX_Dal_Entities');
     Mock::generate('OA_Dal_Maintenance_Priority');
     Mock::generate('OA_DB_Table_Priority');
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:10,代码来源:AllocateZoneImpressions.mtp.test.php


示例15: __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'));
 }
开发者ID:esclapes,项目名称:revive-adserver,代码行数:10,代码来源:Campaign.mtp.test.php


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


示例17: __construct

 /**
  * The constructor method.
  */
 function __construct()
 {
     parent::__construct();
     Mock::generate('MAX_Dal_Entities');
     Mock::generate('OA_Dal_Maintenance_Priority');
     Mock::generate('OA_DB_Table_Priority');
 }
开发者ID:Jaree,项目名称:revive-adserver,代码行数:10,代码来源:AllocateZoneImpressions.mtp.test.php


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


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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Mockery类代码示例发布时间:2022-05-23
下一篇:
PHP Mobile_Detect类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap