public function itDoesNotDisableIfItIsNotAlreadyTheCase() { $request = aRequest()->with('cardwall_on_top', '0')->build(); stub($this->dao)->isEnabled($this->tracker_id)->returns(false); stub($this->dao)->disable()->never(); $this->command->execute($request); }
protected function aOneStepProjectCreationForm($request_data) { $project_manager = mock('ProjectManager'); $request = aRequest()->withParams($request_data)->build(); $creation_request = new Project_OneStepCreation_OneStepCreationRequest($request, $project_manager); return new Project_OneStepCreation_OneStepCreationPresenter($creation_request, array(), $project_manager, array()); }
public function itDoesNotDisableIfItIsNotAlreadyTheCase() { $request = aRequest()->with('use_freestyle_columns', '0')->build(); stub($this->dao)->isFreestyleEnabled($this->tracker_id)->returns(false); stub($this->dao)->disableFreestyleColumns()->never(); $this->command->execute($request); }
protected function aCreationValidator($request_data, $required_custom_descriptions) { $request = aRequest()->withParams($request_data)->build(); $creation_request = new Project_OneStepCreation_OneStepCreationRequest($request, ProjectManager::instance()); $validator = new Project_OneStepCreation_OneStepCreationValidator($creation_request, $required_custom_descriptions); return $validator; }
public function itUpdatesAllColumns() { $request = aRequest()->with('column', array(12 => array('label' => 'Todo', 'bgcolor' => '#000000'), 13 => array('label' => ''), 14 => array('label' => 'Done', 'bgcolor' => '#16ed9d')))->build(); stub($this->dao)->save($this->tracker_id, 12, 'Todo', 0, 0, 0)->at(0); stub($this->dao)->save($this->tracker_id, 14, 'Done', 22, 237, 157)->at(1); stub($this->dao)->save()->count(2); $this->command->execute($request); }
public function itRevokesPermissions() { $request = aRequest()->with(Tracker_Permission_Command::PERMISSION_PREFIX . ProjectUGroup::ANONYMOUS, Tracker_Permission_Command::PERMISSION_SUBMITTER_ONLY)->with(Tracker_Permission_Command::PERMISSION_PREFIX . ProjectUGroup::REGISTERED, Tracker_Permission_Command::PERMISSION_FULL)->build(); $set_permission_request = new Tracker_Permission_PermissionRequest(array()); $set_permission_request->setFromRequest($request, $this->minimal_ugroup_list); $set_permission_request->revoke(ProjectUGroup::REGISTERED); $this->assertNull($set_permission_request->getPermissionType(ProjectUGroup::REGISTERED)); }
public function itDeletesOnlyCustomMappings() { $request = aRequest()->with('custom_mapping', array('13' => '1', '42' => 0, '69' => 0))->build(); stub($this->dao)->delete($this->tracker_id, 69)->at(0)->returns(true); stub($this->dao)->delete()->count(1); stub($this->value_dao)->delete($this->tracker_id, 69)->at(0); stub($this->value_dao)->delete()->count(1); $this->command->execute($request); }
public function setUp() { parent::setUp(); $this->planning_id = '321'; $this->user = aUser()->withId(12)->build(); $this->request = aRequest()->with('planning_id', $this->planning_id)->withUser($this->user)->build(); $this->milestone_factory = mock('Planning_MilestoneFactory'); $this->current_milestone_artifact_id = 444; $milestone = aMilestone()->withArtifact(anArtifact()->withId($this->current_milestone_artifact_id)->build())->build(); stub($this->milestone_factory)->getCurrentMilestone($this->user, $this->planning_id)->returns($milestone); }
public function setUp() { parent::setUp(); $planning_id = "99876387"; $aid = -1; $this->planning_tracker_id = 66; $this->request = aRequest()->withUri("/plugins/agiledashboard/?group_id=104&action=show&planning_id={$planning_id}&aid={$aid}")->build(); $this->planning = aPlanning()->withId($planning_id)->withPlanningTrackerId($this->planning_tracker_id)->build(); $planning_factory = mock('PlanningFactory'); stub($planning_factory)->getPlanning($planning_id)->returns($this->planning); $this->controller = new Planning_ArtifactCreationController($planning_factory, $this->request); }
public function itDeletesAllColumns() { $request = aRequest()->with('column', array(12 => array('label' => ''), 13 => array('label' => '')))->build(); stub($this->field_dao)->deleteCardwall($this->tracker_id)->once(); stub($this->value_dao)->deleteForColumn($this->tracker_id, 12)->at(0); stub($this->value_dao)->deleteForColumn($this->tracker_id, 13)->at(1); stub($this->value_dao)->deleteForColumn()->count(2); stub($this->dao)->delete($this->tracker_id, 12)->at(0); stub($this->dao)->delete($this->tracker_id, 13)->at(1); stub($this->dao)->delete()->count(2); $this->command->execute($request); }
public function setUp() { parent::setUp(); ForgeConfig::store(); ForgeConfig::set('codendi_dir', AGILEDASHBOARD_BASE_DIR . '/../../..'); $this->planning_id = '321'; $this->user = aUser()->withId(12)->build(); $this->request = aRequest()->with('planning_id', $this->planning_id)->withUser($this->user)->build(); $this->milestone_factory = mock('Planning_MilestoneFactory'); $this->current_milestone_artifact_id = 444; $milestone = aMilestone()->withArtifact(anArtifact()->withId($this->current_milestone_artifact_id)->build())->build(); stub($this->milestone_factory)->getLastMilestoneCreated($this->user, $this->planning_id)->returns($milestone); }
function setUp() { parent::setUp(); $this->tracker_id = 3; $project = stub('Project')->getId()->returns(101); $this->tracker = aTracker()->withId($this->tracker_id)->withName('Stories')->withProject($project)->build(); $this->hierarchical_tracker = new Tracker_Hierarchy_HierarchicalTracker($this->tracker, array()); $this->request = aRequest()->withUser(mock('PFUser'))->build(); $this->tracker_factory = new MockTrackerFactory(); $this->dao = new MockTracker_Hierarchy_Dao(); $this->factory = new MockTracker_Hierarchy_HierarchicalTrackerFactory($this->tracker_factory, $this->dao); $this->redirect_url = TRACKER_BASE_URL . "/?tracker={$this->tracker_id}&func=admin-hierarchy"; }
public function itDoesNotUpdateThePostActionIfJobURLIsNotChanged() { $transition = mock('Transition'); $id = 123; $job_url = 'http://www.example.com'; $client = mock('Jenkins_Client'); $condendi_request = aRequest()->with('remove_postaction', array())->with('workflow_postaction_ci_build', array($id => $job_url))->build(); $ci_build_dao = mock('Transition_PostAction_CIBuildDao'); $post_action_ci_build = partial_mock('Transition_PostAction_CIBuild', array('getDao'), array($transition, $id, $job_url, $client)); stub($post_action_ci_build)->getDao()->returns($ci_build_dao); expect($ci_build_dao)->updatePostAction()->never(); expect($GLOBALS['Response'])->addFeedback('error', '*')->never(); $post_action_ci_build->process($condendi_request); }
public function setUp() { parent::setUp(); $this->sprint_planning = aPlanning()->withBacklogTracker(aTracker()->build())->build(); $this->sprint_1 = mock('Planning_Milestone'); stub($this->sprint_1)->hasAncestors()->returns(true); $this->sprint_2 = aMilestone()->withArtifact(aMockArtifact()->withId(1234)->build())->build(); $this->milestone_factory = mock('Planning_MilestoneFactory'); $this->current_user = aUser()->build(); $this->request = aRequest()->withUser($this->current_user)->build(); $this->pane_presenter_builder_factory = mock('AgileDashboard_Milestone_Pane_PanePresenterBuilderFactory'); stub($this->pane_presenter_builder_factory)->getContentPresenterBuilder()->returns(mock('AgileDashboard_Milestone_Pane_Content_ContentPresenterBuilder')); stub($this->pane_presenter_builder_factory)->getPlanningPresenterBuilder()->returns(mock('AgileDashboard_Milestone_Pane_Planning_PlanningPresenterBuilder')); }
public function setUp() { parent::setUp(); ForgeConfig::store(); ForgeConfig::set('codendi_dir', AGILEDASHBOARD_BASE_DIR . '/../../..'); $this->plugin_path = '/plugin/path'; $this->product = aMilestone()->withArtifact(aMockArtifact()->withId(1)->withTitle('Product X')->build())->build(); $this->release = aMilestone()->withArtifact(aMockArtifact()->withId(2)->withTitle('Release 1.0')->build())->build(); $this->sprint = aMilestone()->withArtifact(aMockArtifact()->withId(3)->withTitle('Sprint 1')->build())->build(); $this->nomilestone = stub('Planning_NoMilestone')->getPlanning()->returns(mock('Planning')); $this->milestone_factory = mock('Planning_MilestoneFactory'); $this->project_manager = mock('ProjectManager'); $this->current_user = aUser()->build(); $this->request = aRequest()->withUser($this->current_user)->with('group_id', 102)->build(); $this->project = mock('Project'); stub($this->project_manager)->getProject(102)->returns($this->project); }
public function setUp() { parent::setUp(); $this->request = aRequest()->build(); $this->csrf = mock('CSRFSynchronizerToken'); $this->factory = mock('Git_RemoteServer_GerritServerFactory'); $this->admin = new Git_AdminGerritController($this->csrf, $this->factory); $this->request_new_server = array('host' => 'host', 'port' => '1234', 'login' => 'login', 'identity_file' => '/path/to/file', 'replication_key' => '', 'use_ssl' => 0, 'gerrit_version' => '2.5', 'http_password' => 'azerty'); $this->request_update_existing_server = array('host' => 'g.example.com', 'port' => '1234', 'login' => 'new_login', 'identity_file' => '/path/to/file', 'replication_key' => '', 'use_ssl' => 0, 'gerrit_version' => '2.5', 'http_password' => 'azerty'); $this->request_new_server_with_no_data = array('host' => '', 'port' => '', 'login' => '', 'identity_file' => '', 'replication_key' => '', 'use_ssl' => '', 'gerrit_version' => '2.5', 'http_password' => ''); $this->request_update_existing_server_with_host_and_empty_data = array('host' => 'awesome_host', 'port' => '', 'login' => '', 'identity_file' => '', 'replication_key' => '', 'use_ssl' => '', 'gerrit_version' => '', 'http_password' => ''); $this->request_update_existing_server_with_empty_host = array('host' => '', 'port' => '1234', 'login' => 'new_login', 'identity_file' => '/path/to/file', 'replication_key' => '', 'use_ssl' => 0, 'gerrit_version' => '2.5', 'http_password' => 'azerty'); $this->a_brand_new_server = new Git_RemoteServer_GerritServer(0, 'host', '1234', '80', 'login', '/path/to/file', '', 0, '2.5', 'azerty'); $this->an_existing_server = new Git_RemoteServer_GerritServer(1, 'g.example.com', '1234', '80', 'login', '/path/to/file', '', 0, '2.5', 'azerty'); stub($this->factory)->getServers()->returns(array(1 => $this->an_existing_server)); $this->request->set($this->csrf->getTokenName(), $this->csrf->getToken()); $this->request->set('action', 'gerrit-servers'); }
public function itLinksWithAllHierarchyWhenItWasLinkedToAnAssociatedTracker() { $user = aUser()->build(); $epic_id = 2; $epic = aMockArtifact()->withId(2)->build(); stub($epic)->getAllAncestors($user)->returns(array()); $product = aMockArtifact()->withId(56)->build(); $release_id = 7777; $release = aMockArtifact()->withId($release_id)->build(); stub($release)->getAllAncestors($user)->returns(array($product)); $request = aRequest()->with('link-artifact-id', "{$release_id}")->withUser($user)->build(); $epic->expectNever('linkArtifact'); $release->expectNever('linkArtifact'); $product->expectOnce('linkArtifact', array($epic_id, $user)); $artifact_factory = mock('Tracker_ArtifactFactory'); stub($artifact_factory)->getArtifactById($release_id)->returns($release); $linker = new Planning_ArtifactLinker($artifact_factory); $linker->linkWithParents($request, $epic); }
public function itReturnsJson() { $artifact_id = 55; $artifact_title = 'bla'; $cross_ref = 'task #22'; $edit_url = 'edit'; $accent_color = 'rgb(12,12,12)'; $swimline_id = 215; $drop_into = array('5', '7'); $artifact = aMockArtifact()->withId($artifact_id)->build(); $card_fields = mock('Cardwall_CardFields'); $field1 = mock('Tracker_FormElement_Field_Float'); $field2 = mock('Tracker_FormElement_Field_Selectbox'); $field3 = mock('Tracker_FormElement_Field_Selectbox'); stub($field1)->getJsonValue()->returns(5.1); stub($field2)->getJsonValue()->returns(array(101, 201)); stub($field3)->getJsonValue()->returns(236); stub($field1)->fetchCardValue()->returns("5.1"); stub($field2)->fetchCardValue()->returns('<a href'); stub($field3)->fetchCardValue()->returns('<span>Decorator</span>'); stub($field1)->getName()->returns(Tracker::REMAINING_EFFORT_FIELD_NAME); stub($field2)->getName()->returns(Tracker::ASSIGNED_TO_FIELD_NAME); stub($field3)->getName()->returns(Tracker::IMPEDIMENT_FIELD_NAME); $card_presenter = mock('Cardwall_CardPresenter'); stub($card_presenter)->getTitle()->returns($artifact_title); stub($card_presenter)->getXRef()->returns($cross_ref); stub($card_presenter)->getEditUrl()->returns($edit_url); stub($card_presenter)->getAccentColor()->returns($accent_color); stub($card_presenter)->getSwimlineId()->returns($swimline_id); $card_in_cell_presenter = mock('Cardwall_CardInCellPresenter'); stub($card_in_cell_presenter)->getCardPresenter()->returns($card_presenter); stub($card_in_cell_presenter)->getDropIntoIds()->returns($drop_into); stub($card_in_cell_presenter)->getArtifact()->returns($artifact); stub($card_fields)->getFields()->returns(array($field1, $field2, $field3)); $single_card = new Cardwall_SingleCard($card_in_cell_presenter, $card_fields, mock('Cardwall_UserPreferences_UserPreferencesDisplayUser'), 1111, mock('Cardwall_OnTop_Config_TrackerMapping')); $card_controller = new Cardwall_CardController(aRequest()->withUser(mock('PFUser'))->build(), $single_card); $expected = array($artifact_id => array('title' => $artifact_title, 'xref' => $cross_ref, 'edit_url' => $edit_url, 'accent_color' => $accent_color, 'column_id' => 1111, 'drop_into' => $drop_into, 'fields' => array('remaining_effort' => 5.1, 'assigned_to' => array(101, 201), 'impediment' => 236), 'html_fields' => array('remaining_effort' => '5.1', 'assigned_to' => '<a href', 'impediment' => '<span>Decorator</span>'))); expect($GLOBALS['Response'])->sendJSON($expected)->once(); $card_controller->getCard(); }
public function itHandlesDeleteRequests() { $request = aRequest()->with('remove_postaction', array($this->post_action_id => 1))->build(); $this->dao->expectOnce('deletePostAction', array($this->post_action_id)); $this->post_action->process($request); }
public function itDoesNothingIfTheRequestDoesNotContainTheParameter() { $request = aRequest()->with('func', 'whatever')->build(); expect($GLOBALS['Response'])->sendJSON()->never(); $this->list->process($this->layout, $request, $this->user); }
public function itDoesntReturnScriptWhenInAjax() { $this->setUpAjaxRequestHeaders(); stub($this->hierarchy_factory)->getParentArtifact($this->user, $this->task)->returns(null); $request = aRequest()->with('func', 'artifact-update')->with('from_overlay', '1')->build(); $from_overlay = $this->getProccesAndCaptureOutput($this->layout, $request, $this->user); $this->assertNoPattern('/<script>/i', $from_overlay); $this->restoreAjaxRequestHeaders(); }
public function setUp() { parent::setUp(); $this->sprint_1 = mock('Planning_Milestone'); stub($this->sprint_1)->getArtifactId()->returns(1); stub($this->sprint_1)->getArtifactTitle()->returns('Sprint 1'); stub($this->sprint_1)->getPlanning()->returns(aPlanning()->build()); stub($this->sprint_1)->getLinkedArtifacts()->returns(array()); stub($this->sprint_1)->hasAncestors()->returns(true); $this->sprint_2 = aMilestone()->withArtifact(aMockArtifact()->withId(2)->withTitle('Sprint 2')->build())->build(); $this->milestone_factory = mock('Planning_MilestoneFactory'); $this->project_manager = stub('ProjectManager')->getProject()->returns(mock('Project')); $this->current_user = aUser()->build(); $this->request = aRequest()->withUser($this->current_user)->build(); Tracker_HierarchyFactory::setInstance(mock('Tracker_HierarchyFactory')); }
public function setUp() { parent::setUp(); $this->sprint_planning = aPlanning()->withBacklogTracker(aTracker()->build())->build(); $this->sprint_1 = mock('Planning_Milestone'); stub($this->sprint_1)->getArtifactId()->returns(1); stub($this->sprint_1)->getArtifactTitle()->returns('Sprint 1'); stub($this->sprint_1)->getPlanning()->returns($this->sprint_planning); stub($this->sprint_1)->getLinkedArtifacts()->returns(array()); stub($this->sprint_1)->hasAncestors()->returns(true); $this->sprint_2 = aMilestone()->withArtifact(aMockArtifact()->withId(2)->withTitle('Sprint 2')->build())->build(); $this->milestone_factory = mock('Planning_MilestoneFactory'); $this->project_manager = stub('ProjectManager')->getProject()->returns(mock('Project')); $this->current_user = aUser()->build(); $this->request = aRequest()->withUser($this->current_user)->build(); $this->view_builder = stub('Planning_ViewBuilder')->build()->returns(mock('Tracker_CrossSearch_SearchContentView')); $this->hierarchy_factory = mock('Tracker_HierarchyFactory'); stub($this->hierarchy_factory)->getHierarchy()->returns(new Tracker_Hierarchy()); }
public function itRoutesToTheArtifactPlannificationWhenTheAidIsSetToAPositiveNumber() { $request = aRequest()->with('aid', '732')->withUri('someurl')->build(); $this->router->expectOnce('renderAction', array(new IsAExpectation('Planning_MilestoneController'), 'show', $request, '*', '*')); $this->router->routeShowPlanning($request); }
public function itCreatesANewMappingField() { $request = aRequest()->with('add_mapping_on', '42')->build(); stub($this->dao)->create($this->tracker_id, 42, null)->once(); $this->command->execute($request); }
public function itProvidesFeedbackIfRulesSuccessfullyUpdated() { $request = aRequest()->with(self::PARAMETER_UPDATE_RULES, array("{$this->rule_42_id}" => array(self::PARAMETER_SOURCE_FIELD => '44', self::PARAMETER_TARGET_FIELD => '22', self::PARAMETER_COMPARATOR => '>'), "{$this->rule_66_id}" => array(self::PARAMETER_SOURCE_FIELD => '22', self::PARAMETER_TARGET_FIELD => '44', self::PARAMETER_COMPARATOR => '<')))->build(); stub($this->date_factory)->save()->returns(true); expect($GLOBALS['Response'])->addFeedback('info', '*')->once(); $this->processRequestAndExpectRedirection($request); }
public function itRendersTheEditTemplate() { $group_id = 123; $planning_id = 456; $planning = aPlanning()->withGroupId($group_id)->withId($planning_id)->build(); $request = aRequest()->with('planning_id', $planning_id)->with('action', 'edit')->build(); $planning_factory = mock('PlanningFactory'); stub($planning_factory)->getPlanning($planning_id)->returns($planning); stub($planning_factory)->getAvailableBacklogTrackers('*', $group_id)->returns(array()); stub($planning_factory)->getAvailablePlanningTrackers('*', $group_id)->returns(array()); $kanban_factory = stub('AgileDashboard_KanbanFactory')->getKanbanTrackerIds()->returns(array()); $controller = partial_mock('Planning_Controller', array('renderToString'), array($request, $planning_factory, mock('Planning_ShortAccessFactory'), mock('Planning_MilestoneFactory'), mock('ProjectManager'), mock('AgileDashboard_XMLFullStructureExporter'), '/path/to/theme', '/path/to/plugin', mock('AgileDashboard_KanbanManager'), mock('AgileDashboard_ConfigurationManager'), $kanban_factory, mock('PlanningPermissionsManager'))); $controller->expectOnce('renderToString', array('edit', new IsAExpectation('Planning_FormPresenter'))); $controller->edit(); }
protected function aCreationRequest($request_data) { $request = aRequest()->withParams($request_data)->build(); return new Project_OneStepCreation_OneStepCreationRequest($request, $this->project_manager); }
public function itCreatesANewColumn() { $request = aRequest()->with('new_column', 'On Going')->build(); stub($this->dao)->create($this->tracker_id, 'On Going')->once(); $this->command->execute($request); }
public function itUpdatesMappingFieldValuesWhenAValueIsRemoved() { $request = aRequest()->with('mapping_field', array('69' => array('field' => '321', 'values' => array('11' => array('9001')))))->build(); stub($this->value_dao)->deleteAllFieldValues()->once(); stub($this->value_dao)->save()->once(); $this->command->execute($request); }