public function setUp() { parent::setUp(); $tracker_user_story_id = 103; $user_story_id = 107; $submitted_by = 102; $submitted_on = 1234567890; $use_artifact_permissions = false; $tracker = aMockTracker()->withId($this->tracker_id)->build(); $this->layout = mock('Tracker_IDisplayTrackerLayout'); $this->request = aRequest()->with('func', 'artifact-update')->build(); $this->user = mock('PFUser'); $this->formelement_factory = mock('Tracker_FormElementFactory'); $this->hierarchy_factory = mock('Tracker_HierarchyFactory'); $this->computed_field = mock('Tracker_FormElement_Field_Computed'); $this->us_computed_field = mock('Tracker_FormElement_Field_Computed'); $this->user_story = mock('Tracker_Artifact'); $tracker_user_story = aMockTracker()->withId($tracker_user_story_id)->build(); stub($this->user_story)->getTrackerId()->returns($tracker_user_story_id); stub($this->user_story)->getTracker()->returns($tracker_user_story); stub($this->user_story)->getId()->returns($user_story_id); $this->task = partial_mock('Tracker_Artifact', array('createNewChangeset'), array($this->artifact_id, $this->tracker_id, $submitted_by, $submitted_on, $use_artifact_permissions)); $this->task->setHierarchyFactory($this->hierarchy_factory); $this->task->setTracker($tracker); $this->task->setFormElementFactory($this->formelement_factory); stub($this->task)->createNewChangeset()->returns(true); stub($this->formelement_factory)->getComputableFieldByNameForUser($tracker_user_story_id, Tracker::REMAINING_EFFORT_FIELD_NAME, $this->user)->returns($this->us_computed_field); stub($this->computed_field)->fetchCardValue($this->task)->returns(42); stub($this->us_computed_field)->fetchCardValue($this->user_story)->returns(23); $this->event_manager = mock('EventManager'); $this->action = new Tracker_Action_UpdateArtifact($this->task, $this->formelement_factory, $this->event_manager); }
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())); }
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'); }
public function aSystemEventWithParameter($parameters) { $id = $type = $owner = $priority = $status = $create_date = $process_date = $end_date = $log = null; $event = partial_mock($this->klass, array('getWikiPage'), array($id, $type, $owner, $parameters, $priority, $status, $create_date, $process_date, $end_date, $log)); $event->injectDependencies($this->actions); return $event; }
public function setUp() { parent::setUp(); EventManager::setInstance(mock('EventManager')); $this->rm = partial_mock('ReferenceManager', array('_getReferenceDao', '_getCrossReferenceDao', 'loadReservedKeywords', 'getGroupIdFromArtifactIdForCallbackFunction', 'getGroupIdFromArtifactId')); $this->rm->__construct(); }
public function setUp() { parent::setUp(); $changeset_factory = mock('Tracker_Artifact_ChangesetFactory'); $this->tracker = aMockTracker()->withId(1)->build(); $this->new_artifact = partial_mock('Tracker_Artifact', array('createNewChangeset')); $this->new_artifact->setId($this->new_artifact_id); $this->layout = mock('Tracker_IDisplayTrackerLayout'); $this->user = mock('PFUser'); $this->xml_exporter = mock('Tracker_XML_Exporter_ArtifactXMLExporter'); $this->xml_importer = mock('Tracker_Artifact_XMLImport'); $this->xml_updater = mock('Tracker_XML_Updater_ChangesetXMLUpdater'); $this->file_updater = mock('Tracker_XML_Updater_TemporaryFileXMLUpdater'); $this->from_changeset = stub('Tracker_Artifact_Changeset')->getId()->returns($this->changeset_id); $this->from_artifact = partial_mock('Tracker_Artifact', array('getChangesetFactory')); $this->from_artifact->setId($this->artifact_id); $this->from_artifact->setTracker($this->tracker); $this->from_artifact->setChangesets(array($this->changeset_id => $this->from_changeset)); stub($this->from_artifact)->getChangesetFactory()->returns($changeset_factory); stub($this->from_changeset)->getArtifact()->returns($this->from_artifact); $this->children_xml_exporter = mock('Tracker_XML_Exporter_ChildrenXMLExporter'); $this->children_xml_importer = mock('Tracker_XML_Importer_ChildrenXMLImporter'); $this->artifacts_imported_mapping = mock('Tracker_XML_Importer_ArtifactImportedMapping'); $backend_logger = mock("BackendLogger"); $this->logger = new Tracker_XML_Importer_CopyArtifactInformationsAggregator($backend_logger); $this->submitted_values = array(); $this->artifact_factory = mock('Tracker_ArtifactFactory'); stub($this->artifact_factory)->getArtifactByIdUserCanView($this->user, $this->artifact_id)->returns($this->from_artifact); $this->request = aRequest()->with('from_artifact_id', $this->artifact_id)->with('from_changeset_id', $this->changeset_id)->with('artifact', $this->submitted_values)->build(); $this->action = new Tracker_Action_CopyArtifact($this->tracker, $this->artifact_factory, $this->xml_exporter, $this->xml_importer, $this->xml_updater, $this->file_updater, $this->children_xml_exporter, $this->children_xml_importer, $this->artifacts_imported_mapping, $this->logger); $this->a_mocked_artifact = mock("Tracker_Artifact"); }
public function setUp() { parent::setUp(); $this->manifest_manager = mock('Git_Mirror_ManifestManager'); $this->event = partial_mock('SystemEvent_GIT_GROKMIRROR_MANIFEST_CHECK', array('done', 'warning', 'error', 'getId')); $this->event->injectDependencies($this->manifest_manager); }
public function setUp() { parent::setUp(); $this->dao = mock('Git_GitoliteHousekeeping_GitoliteHousekeepingDao'); $this->logger = mock('Logger'); $this->gitgc = partial_mock('Git_GitoliteHousekeeping_GitoliteHousekeepingGitGc', array('execGitGcAsAppAdm'), array($this->dao, $this->logger, '/path/to/gitolite_admin_working_copy')); }
public function setUp() { parent::setUp(); $this->ls_group_return = array('Administrators', 'Anonymous Users', 'Non-Interactive Users', 'Project Owners', 'Registered Users', 'project/project_members', 'project/project_admins', 'project/group_from_ldap'); $this->gerrit_driver = partial_mock('Git_Driver_GerritLegacy', array('listGroups')); stub($this->gerrit_driver)->listGroups()->returns($this->ls_group_return); $this->gerrit_server = mock('Git_RemoteServer_GerritServer'); }
function testURLWithBuildWithParams() { $job = partial_mock('HudsonJob', array('getHudsonControler')); stub($job)->getHudsonControler()->returns(mock('hudson')); $job->__construct('http://shunt.cro.enalean.com:8080/job/build_params/buildWithParameters?Stuff=truc'); $this->assertEqual($job->getJobUrl(), 'http://shunt.cro.enalean.com:8080/job/build_params/api/xml'); $this->assertEqual($job->getDoBuildUrl(), 'http://shunt.cro.enalean.com:8080/job/build_params/buildWithParameters?Stuff=truc'); }
public function setUp() { parent::setUp(); $this->ls_project_return = array('All-Projects', 'project'); $this->gerrit_driver = partial_mock('Git_Driver_GerritLegacy', array('listParentProjects')); stub($this->gerrit_driver)->listParentProjects()->returns($this->ls_project_return); $this->gerrit_server = mock('Git_RemoteServer_GerritServer'); }
public function setUp() { parent::setUp(); $this->gerrit_server = mock('Git_RemoteServer_GerritServer'); $this->ssh = mock('Git_Driver_Gerrit_RemoteSSHCommand'); $this->logger = mock('BackendLogger'); $this->driver = partial_mock('Git_Driver_GerritLegacy', array('getGroupId'), array($this->ssh, $this->logger)); }
public function setUp() { parent::setUp(); $this->ssh_key_dumper = mock('Git_Gitolite_SSHKeyDumper'); $this->gerrit_server_factory = mock('Git_RemoteServer_GerritServerFactory'); $this->event = partial_mock('SystemEvent_GIT_GERRIT_ADMIN_KEY_DUMP', array('done', 'error')); $this->event->injectDependencies($this->gerrit_server_factory, $this->ssh_key_dumper); }
public function setUp() { parent::setUp(); $this->ssh = partial_mock('Git_Driver_Gerrit_RemoteSSHCommand', array('sshExec')); $this->logger = mock('Logger'); $this->ssh->__construct($this->logger); $this->config = new Git_RemoteServer_GerritServer(1, $this->host, $this->ssh_port, $this->http_port, $this->login, $this->identity_file, $this->replication_key, $this->use_ssl, $this->gerrit_version, $this->http_password); }
public function setUp() { parent::setUp(); $this->tracker_id = 12; $this->tracker = aTracker()->withId($this->tracker_id)->build(); $this->user_id = 32; $this->user = aUser()->withId($this->user_id)->build(); $this->report_factory = partial_mock('Tracker_ReportFactory', array('getReportsByTrackerId')); }
/** * Not exactly a unit test but, then again, we are testing a plugin! */ public function itCreatesSemantic() { $effort_factory = partial_mock('AgileDashboard_Semantic_InitialEffortFactory', array()); $plugin = partial_mock('AgileDashboardPlugin', array('getSemanticInitialEffortFactory')); stub($plugin)->getSemanticInitialEffortFactory()->returns($effort_factory); $plugin->tracker_event_semantic_from_xml($this->parameters); $this->assertNotNull($this->parameters['semantic']); $this->assertIsA($this->parameters['semantic'], 'AgileDashBoard_Semantic_InitialEffort'); }
public function itSendsJSON() { $response = partial_mock('Response', array('setContentType')); stub($response)->setContentType('application/json')->once(); ob_start(); $response->sendJSON(array("toto")); $output = ob_get_clean(); $this->assertEqual($output, '["toto"]'); }
public function testJSon() { $id = 123; $label = 'Reopen'; $value = partial_mock('Tracker_FormElement_Field_List_BindValue', array('getLabel', '__toString')); $value->setReturnValue('getLabel', $label); $value->setId($id); $this->assertEqual(json_encode($value->fetchForOpenListJson()), '{"id":123,"value":"b123","caption":"Reopen","rest_value":"Reopen"}'); }
public function itHasJsonRepresentation() { $timestamp = mktime(1, 1, 1, 9, 25, 2013); $changeset = partial_mock('Tracker_Artifact_Changeset', array('getChangeContentForJson'), array(15, aMockArtifact()->build(), 45, $timestamp, '')); $template_renderer = mock('TemplateRenderer'); stub($template_renderer)->renderToString()->returns('body'); $json_formatter = new Tracker_Artifact_ChangesetJsonFormatter($template_renderer); $this->assertEqual($json_formatter->format($changeset), array('id' => 15, 'submitted_by' => 45, 'submitted_on' => date('c', $timestamp), 'email' => '', 'html' => 'body')); }
function setUp() { parent::setUp(); $GLOBALS['Language']->setReturnValue('getText', 'actions_no_repository_forked', array('plugin_git', 'actions_no_repository_forked', '*')); $GLOBALS['Language']->setReturnValue('getText', 'successfully_forked', array('plugin_git', 'successfully_forked', '*')); $git_plugin = stub('GitPlugin')->areFriendlyUrlsActivated()->returns(false); $url_manager = new Git_GitRepositoryUrlManager($git_plugin); $this->gitAction = partial_mock('GitActions', array('getText', 'addData', 'getGitRepository', 'save'), array(mock('Git'), mock('Git_SystemEventManager'), mock('GitRepositoryFactory'), mock('GitRepositoryManager'), mock('Git_RemoteServer_GerritServerFactory'), stub('Git_Driver_Gerrit_GerritDriverFactory')->getDriver()->returns(mock('Git_Driver_Gerrit')), mock('Git_Driver_Gerrit_UserAccountManager'), mock('Git_Driver_Gerrit_ProjectCreator'), mock('Git_Driver_Gerrit_Template_TemplateFactory'), mock('ProjectManager'), mock('GitPermissionsManager'), $url_manager, mock('Logger'), mock('Git_Backend_Gitolite'), mock('Git_Mirror_MirrorDataMapper'), mock('ProjectHistoryDao'), mock('GitRepositoryMirrorUpdater'))); }
public function aSystemEventWithParameter($parameters) { $id = $type = $owner = $priority = $status = $create_date = $process_date = $end_date = $log = null; $event = partial_mock('SystemEvent_FULLTEXTSEARCH_DOCMAN_WIKI_INDEX', array('getWikiPage'), array($id, $type, $owner, $parameters, $priority, $status, $create_date, $process_date, $end_date, $log)); $this->wiki_page = stub('WikiPage')->getMetadata()->returns(array()); stub($event)->getWikiPage()->returns($this->wiki_page); $event->injectDependencies($this->actions, $this->item_factory, $this->version_factory, $this->link_version_factory); return $event; }
public function setUp() { parent::setUp(); $this->project = mock('Project'); $this->permission_type = 'FOO'; $this->object_id = 'BAR'; $this->permissions_manager = partial_mock('PermissionsManager', array('getAuthorizedUgroups')); ForgeConfig::store(); }
function partial_stub($classname_or_simpletest_mock, array $mocked_methods) { if (is_object($classname_or_simpletest_mock)) { $mock = $classname_or_simpletest_mock; } else { $mock = partial_mock($classname_or_simpletest_mock); } return new OngoingIntelligentStub($mock); }
public function setUp() { parent::setUp(); $this->process = mock('SystemEventProcess'); $this->object = mock('IRunInAMutex'); $this->process_manager = mock('SystemEventProcessManager'); $this->mutex = partial_mock('SystemEventProcessorMutex', array('checkCurrentUserProcessOwner'), array($this->process_manager, $this->object)); stub($this->object)->getProcess()->returns($this->process); stub($this->process)->getQueue()->returns(SystemEvent::DEFAULT_QUEUE); }
public function itCreatesCorrectQueryWithExactSearchTerm() { $this->dao = partial_mock('SystemEventDao', array('retrieve'), array($this->da)); $expected_sql = 'SELECT * FROM system_event WHERE type IN (MY_IMAGINARY_EVENT) AND status IN (ONGOING) AND parameters LIKE abc'; stub($this->dao)->retrieve($expected_sql)->once(); $this->dao->searchWithParam('all', $this->search_term, $this->event_type, $this->status); }
public function setUp() { parent::setUp(); $this->language_manager = mock('MediawikiLanguageManager'); $this->welcome_page_manager = partial_mock('MediawikiWelcomePageManager', array('exterminate'), array($this->language_manager)); $this->project = mock('Project'); $this->request = mock('HTTPRequest'); $this->service = mock('ServiceMediawiki'); stub($this->project)->getService(MediaWikiPlugin::SERVICE_SHORTNAME)->returns($this->service); }
public function setUp() { parent::setUp(); $this->formelement_factory = mock('Tracker_FormElementFactory'); $this->tracker = mock('Tracker'); $this->user = mock('PFUser'); $this->semantic_manager = mock('Tracker_SemanticManager'); $this->builder = partial_mock('Tracker_REST_TrackerRestBuilder', array('getSemanticManager'), array($this->formelement_factory)); stub($this->builder)->getSemanticManager()->returns($this->semantic_manager); }
public function itDelegatesRetrievalOfTheOldValueToTheDaoWhenNoTimestampGiven() { $user = aUser()->build(); $value_dao = stub('Tracker_FormElement_Field_Value_FloatDao')->getLastValue()->returns(array('value' => '123.45')); $artifact = aMockArtifact()->build(); $field = partial_mock('Tracker_FormElement_Field_Float', array('getId', 'userCanRead', 'getValueDao')); stub($field)->userCanRead($user)->returns(true); stub($field)->getValueDao()->returns($value_dao); $actual_value = $field->getComputedValue($user, $artifact); $this->assertEqual('123.45', $actual_value); }
public function setUp() { parent::setUp(); $this->project_manager = mock('ProjectManager'); $this->url_processor = mock('Url'); $this->fixtures_dir = dirname(__FILE__) . '/_fixtures'; $this->factory = partial_mock('Tuleap_CustomToursFactory', array('getTourListJson'), array($this->project_manager, $this->url_processor)); $this->user = mock('PFUser'); ForgeConfig::set('sys_custom_incdir', $this->fixtures_dir); stub($this->user)->getLocale()->returns('es_CU'); }
public function setUp() { $GLOBALS['alias_file'] = dirname(__FILE__) . '/_fixtures/etc/aliases.codendi'; $this->alias_file = $GLOBALS['alias_file']; $udao = mock('UserDao'); stub($udao) ->searchByStatus() ->returnsDar( array( "user_name"=> "user1", "email" => "*****@*****.**" ), array( "user_name"=> "user2", "email" => "*****@*****.**" ), array( "user_name"=> "user3", "email" => "*****@*****.**" ) ); $listdao = mock('MailingListDao'); stub($listdao) ->searchAllActiveML() ->returnsDar( array("list_name"=> "list1"), array("list_name"=> "list2"), array("list_name"=> "list3"), array("list_name"=> "list4") ); $this->backend = partial_mock( 'BackendAliases', array( 'getUserDao', 'getMailingListDao', 'system' ) ); stub($this->backend)->getUserDao()->returns($udao); stub($this->backend)->getMailingListDao()->returns($listdao); stub($this->backend)->system()->returns(true); $plugin = new BackendAliasesTest_FakePlugin(); EventManager::instance()->addListener( Event::BACKEND_ALIAS_GET_ALIASES, $plugin, 'hook', false, 0 ); }