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


PHP Mock类代码示例

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


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


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