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


PHP mock函数代码示例

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


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

示例1: testStoreEventsDoNotOverrideUsers

 function testStoreEventsDoNotOverrideUsers()
 {
     $listeningUsers = new ArrayIterator(array(array('user_id' => 1, 'object_id' => 1), array('user_id' => 2, 'object_id' => 1), array('user_id' => 3, 'object_id' => 1)));
     $user1 = mock('PFUser');
     $user1->setReturnValue('getId', 1);
     $user2 = mock('PFUser');
     $user2->setReturnValue('getId', 2);
     $user3 = mock('PFUser');
     $user3->setReturnValue('getId', 3);
     $um = new MockUserManager();
     $um->setReturnValueAt(0, 'getUserById', $user1);
     $um->setReturnValueAt(1, 'getUserById', $user2);
     $um->setReturnValueAt(2, 'getUserById', $user3);
     $dpm = new MockDocman_PermissionsManager();
     $dpm->setReturnValue('userCanRead', true);
     $dpm->setReturnValue('userCanAccess', true);
     $item = new MockDocman_Item();
     $item->setReturnValue('getId', 1);
     $params = array('item' => $item);
     $nm = new Docman_NotificationsManager_DeleteTestVersion();
     $nm->setReturnValue('_getListeningUsers', $listeningUsers);
     $nm->setReturnValue('_getUserManager', $um);
     $nm->setReturnValue('_getPermissionsManager', $dpm);
     $nm->_listeners = array();
     $nm->_storeEvents(1, 'removed', $params);
     $this->assertEqual($user1, $nm->_listeners[1]['user']);
     $this->assertEqual($user2, $nm->_listeners[2]['user']);
     $this->assertEqual($user3, $nm->_listeners[3]['user']);
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:29,代码来源:NotificationsManager_DeleteTest.php

示例2: aSystemEventWithParameter

 public function aSystemEventWithParameter($parameters)
 {
     $id = $type = $owner = $priority = $status = $create_date = $process_date = $end_date = $log = null;
     $event = new SystemEvent_FULLTEXTSEARCH_TRACKER_REINDEX_PROJECT($id, $type, $owner, $parameters, $priority, $status, $create_date, $process_date, $end_date, $log);
     $event->injectDependencies($this->actions, mock('TrackerFactory'), mock('FullTextSearch_TrackerSystemEventManager'), mock('TruncateLevelLogger'));
     return $event;
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:SystemEvent_FULLTEXTSEARCH_TRACKER_REINDEX_PROJECTTest.php

示例3: setUp

 public function setUp()
 {
     parent::setUp();
     $this->target_tracker = aTracker()->withId(12)->withChildren(array())->build();
     $this->formelement_factory = mock('Tracker_FormElementFactory');
     $this->factory = new Tracker_Workflow_Trigger_RulesBuilderFactory($this->formelement_factory);
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:RulesBuilderFactoryTest.php

示例4: setUp

 public function setUp()
 {
     parent::setUp();
     $this->dao = mock('Git_Driver_Gerrit_ProjectCreatorStatusDao');
     $this->repository = mock('GitRepository');
     $this->gerrit_status = new Git_Driver_Gerrit_ProjectCreatorStatus($this->dao);
 }
开发者ID:blestab,项目名称:tuleap,代码行数:7,代码来源:ProjectCreatorStatusTest.php

示例5: setUp

 public function setUp()
 {
     parent::setUp();
     $this->ldap = mock('LDAP');
     stub($this->ldap)->getLDAPParam('dn')->returns('dc=tuleap,dc=com');
     $this->apache = new LDAP_SVN_Apache($this->ldap, mock('LDAP_ProjectManager'), array());
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:LDAP_SVN_ApacheTest.php

示例6: setUp

 public function setUp()
 {
     $this->field_122 = aSelectBoxField()->withId(122)->build();
     $this->field_123 = aSelectBoxField()->withId(123)->build();
     $this->field_124 = aSelectBoxField()->withId(124)->build();
     $this->status_field = aSelectBoxField()->withId(125)->build();
     $group_id = 234;
     $this->tracker = aMockTracker()->withId(3)->withProjectId($group_id)->build();
     $this->tracker_10 = aMockTracker()->withId(10)->withStatusField($this->status_field)->build();
     $this->tracker_20 = aMockTracker()->withId(20)->build();
     $project_trackers = array(3 => $this->tracker, 10 => $this->tracker_10, 20 => $this->tracker_20);
     $tracker_factory = stub('TrackerFactory')->getTrackersByGroupId($group_id)->returns($project_trackers);
     foreach ($project_trackers as $t) {
         stub($tracker_factory)->getTrackerById($t->getId())->returns($t);
     }
     $element_factory = mock('Tracker_FormElementFactory');
     stub($element_factory)->getFieldById(123)->returns($this->field_123);
     stub($element_factory)->getFieldById(124)->returns($this->field_124);
     stub($element_factory)->getUsedSbFields($this->tracker_10)->returns(array($this->field_122, $this->field_123));
     stub($element_factory)->getUsedSbFields()->returns(array());
     $this->dao = mock('Cardwall_OnTop_ColumnMappingFieldDao');
     $this->value_mapping_factory = mock('Cardwall_OnTop_Config_ValueMappingFactory');
     stub($this->value_mapping_factory)->getMappings()->returns(array());
     stub($this->value_mapping_factory)->getStatusMappings()->returns(array());
     $this->columns = new Cardwall_OnTop_Config_ColumnFreestyleCollection(array(new Cardwall_Column(1, 'Todo', 'white', 'black'), new Cardwall_Column(2, 'On Going', 'white', 'black'), new Cardwall_Column(3, 'Done', 'white', 'black')));
     $this->factory = new Cardwall_OnTop_Config_TrackerMappingFactory($tracker_factory, $element_factory, $this->dao, $this->value_mapping_factory);
 }
开发者ID:nterray,项目名称:tuleap,代码行数:27,代码来源:TrackerMappingFactoryTest.php

示例7: testRemoveMailByProjectPrivateRepositoryErrorDaoRemoving

 public function testRemoveMailByProjectPrivateRepositoryErrorDaoRemoving()
 {
     $prm = new PostReceiveMailManagerTestVersion();
     $user = mock('PFUser');
     $user->setReturnValue('isMember', False);
     $user->setReturnValue('getEmail', "codendiadm@codendi.org");
     $prj = new MockProject($this);
     $prj->setReturnValue('getId', 1750);
     $repositoryList = array(array('project_id' => '1750', 'repository_id' => 2515));
     $gitDao = new MockGitDao($this);
     $prm->setReturnValue('_getGitDao', $gitDao);
     $gitDao->setReturnValue('getProjectRepositoryList', $repositoryList);
     foreach ($repositoryList as $row) {
         $repo = new MockGitRepository($this);
         $prm->setReturnValue('_getGitRepository', $repo);
         $repo->setReturnValue('isPrivate', True);
         $repo->setReturnValue('load', True);
         $backend = new MockGitBackend();
         $repo->SetReturnValue('getBackend', $backend);
     }
     $prm->setReturnValue('removeMailByRepository', False);
     $GLOBALS['Language']->setReturnValue('getText', 'Mail not removed');
     $GLOBALS['Response']->expectOnce('addFeedback', array('error', $GLOBALS['Language']->getText('plugin_git', 'dao_error_remove_notification')));
     $prm->removeMailByProjectPrivateRepository($prj->getId(), $user);
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:25,代码来源:Git_PostReceiveMailManagerTest.php

示例8: setUp

 public function setUp()
 {
     parent::setUp();
     $this->bind = partial_mock('Tracker_FormElement_Field_List_Bind4Tests', array('getAllValues'));
     $this->v1 = mock('Tracker_FormElement_Field_List_BindValue');
     $this->v2 = mock('Tracker_FormElement_Field_List_BindValue');
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:Tracker_FormElement_Field_List_BindTest.php

示例9: itMayWrapAnObject

 public function itMayWrapAnObject()
 {
     $object = mock('stdClass');
     $node = new TreeNode();
     $node->setObject($object);
     $this->assertEqual($object, $node->getObject());
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:TreeNodeTest.php

示例10: setUp

 public function setUp()
 {
     /*
                    Epic
     Release  ----,-- Story
       Sprint ---'      Task
     */
     $this->epic_tracker = aTracker()->withId('epic')->withParent(null)->build();
     $this->story_tracker = aTracker()->withId('story')->withParent($this->epic_tracker)->build();
     $this->task_tracker = aTracker()->withId('task')->withParent($this->story_tracker)->build();
     $this->release_tracker = aTracker()->withId('release')->withParent(null)->build();
     $this->sprint_tracker = aTracker()->withId('sprint')->withParent($this->epic_tracker)->build();
     $release_planning = stub('Planning')->getPlanningTracker()->returns($this->release_tracker);
     stub($release_planning)->getPlanningTrackerId()->returns('release');
     $sprint_planning = stub('Planning')->getPlanningTracker()->returns($this->sprint_tracker);
     stub($sprint_planning)->getPlanningTrackerId()->returns('sprint');
     $this->hierarchy = mock('Tracker_Hierarchy');
     stub($this->hierarchy)->sortTrackerIds()->returns(array('release', 'sprint'));
     $this->hierarchy_factory = mock('Tracker_HierarchyFactory');
     stub($this->hierarchy_factory)->getHierarchy()->returns($this->hierarchy);
     $this->planning_factory = mock('PlanningFactory');
     stub($this->planning_factory)->getPlanningsByBacklogTracker($this->task_tracker)->returns(array());
     stub($this->planning_factory)->getPlanningsByBacklogTracker($this->story_tracker)->returns(array($sprint_planning, $release_planning));
     stub($this->planning_factory)->getPlanningsByBacklogTracker($this->epic_tracker)->returns(array());
     $this->provider = new AgileDashboard_Planning_NearestPlanningTrackerProvider($this->planning_factory);
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:26,代码来源:NearestPlanningTrackerProviderTest.php

示例11: setUp

 public function setUp()
 {
     parent::setUp();
     ForgeConfig::store();
     ForgeConfig::set('sys_logger_level', 'debug');
     $this->ldap = partial_mock('LDAP', array('search'), array($this->ldap_params, mock('TruncateLevelLogger'), new LdapQueryEscaper()));
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:LDAPTest.php

示例12: setUp

 public function setUp()
 {
     parent::setUp();
     /*
     Product          Epic
       Release  ----,-- Story
         Sprint ---'      Task
     */
     $this->user = aUser()->build();
     $this->release_tracker_id = 101;
     $this->sprint_tracker_id = 1001;
     $this->task_tracker_project_id = 200;
     $this->epic_tracker = aTracker()->withId('epic')->withParent(null)->build();
     $this->story_tracker = aTracker()->withId('story')->withParent($this->epic_tracker)->build();
     $this->task_tracker = aTracker()->withId('task')->withProjectId($this->task_tracker_project_id)->withParent($this->story_tracker)->build();
     $this->product_tracker = aTracker()->withId('product')->withParent(null)->build();
     $this->release_tracker = aTracker()->withId($this->release_tracker_id)->withParent($this->product_tracker)->build();
     $this->sprint_tracker = aTracker()->withId($this->sprint_tracker_id)->withParent($this->epic_tracker)->build();
     $release_planning = stub('Planning')->getPlanningTracker()->returns($this->release_tracker);
     $sprint_planning = stub('Planning')->getPlanningTracker()->returns($this->sprint_tracker);
     $top_planning = stub('Planning')->getBacklogTrackersIds()->returns(array($this->release_tracker_id, $this->sprint_tracker_id));
     $this->planning_factory = mock('PlanningFactory');
     stub($this->planning_factory)->getPlanningByPlanningTracker($this->product_tracker)->returns(null);
     stub($this->planning_factory)->getPlanningByPlanningTracker($this->release_tracker)->returns($release_planning);
     stub($this->planning_factory)->getPlanningByPlanningTracker($this->sprint_tracker)->returns($sprint_planning);
     stub($this->planning_factory)->getVirtualTopPlanning($this->user, $this->task_tracker_project_id)->returns($top_planning);
     $this->hierarchy_factory = mock('Tracker_HierarchyFactory');
     stub($this->hierarchy_factory)->getAllParents($this->sprint_tracker)->returns(array($this->release_tracker, $this->product_tracker));
     $this->dao = mock('AgileDashboard_Milestone_MilestoneDao');
     stub($this->dao)->getAllMilestoneByTrackers(array($this->release_tracker_id, $this->sprint_tracker_id))->returnsDar(array('m101_id' => '123', 'm101_title' => 'Tuleap 6.5', 'm1001_id' => '1231', 'm1001_title' => 'Sprint 31'), array('m101_id' => '123', 'm101_title' => 'Tuleap 6.5', 'm1001_id' => '1232', 'm1001_title' => 'Sprint 32'), array('m101_id' => '124', 'm101_title' => 'Tuleap 6.6', 'm1001_id' => '1241', 'm1001_title' => 'Sprint 33'));
     $this->nearest_planning_tracker_provider = mock('AgileDashboard_Planning_NearestPlanningTrackerProvider');
     $this->provider = new AgileDashboard_Milestone_MilestoneReportCriterionOptionsProvider($this->nearest_planning_tracker_provider, $this->dao, $this->hierarchy_factory, $this->planning_factory);
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:33,代码来源:MilestoneReportCriterionOptionsProviderTest.php

示例13: setUp

 public function setUp()
 {
     parent::setUp();
     $this->user_manager = mock('UserManager');
     $this->logger = mock('Logger');
     $this->user = new WillBeCreatedUser('cstevens', 'Cat Stevens', 'cstevens@example.com', 'S');
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:WillBeCreatedUserTest.php

示例14: setUp

 function setUp()
 {
     $this->user = mock('PFUser');
     $this->user->setReturnValue('getId', 1234);
     $this->itemId = 1848;
     $this->docmanPm = new Docman_PermissionsManagerTestLock($this);
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:PermissionsManagerLockTest.php

示例15: testDiff

 public function testDiff()
 {
     $this->field = mock('Tracker_FormElement_Field_Integer');
     $int_1 = new Tracker_Artifact_ChangesetValue_Integer(111, $this->field, false, 66);
     $int_2 = new Tracker_Artifact_ChangesetValue_Integer(111, $this->field, false, 666);
     $this->assertEqual($int_1->diff($int_2), 'changed from 666 to 66');
 }
开发者ID:ansarbek,项目名称:tuleap,代码行数:7,代码来源:Tracker_Artifact_ChangesetValue_IntegerTest.php


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