1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) Enalean, 2014. All rights reserved |
4
|
|
|
* |
5
|
|
|
* This file is a part of Tuleap. |
6
|
|
|
* |
7
|
|
|
* Tuleap is free software; you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* Tuleap is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License |
18
|
|
|
* along with Tuleap. If not, see <http://www.gnu.org/licenses/ |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
require_once dirname(__FILE__).'/../../lib/autoload.php'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* PUT /cards/:id cannot update solo card |
25
|
|
|
* |
26
|
|
|
* In the context of a sprint Cardwall, if we change through direct edition, the |
27
|
|
|
* value of the field "Story Point" of a backlog "User Story" ,we receive the |
28
|
|
|
* error "column_id is required", after submitting this sprint. |
29
|
|
|
* |
30
|
|
|
* @see https://tuleap.net/plugins/tracker/?aid=6430 |
31
|
|
|
* @group Regressions |
32
|
|
|
*/ |
33
|
|
|
class Regressions_PutSoloCardTest extends RestBase { |
34
|
|
|
|
35
|
|
|
/** @var Test_Rest_TrackerFactory */ |
36
|
|
|
private $tracker_test_helper; |
37
|
|
|
private $project_id; |
38
|
|
|
private $story; |
39
|
|
|
private $task; |
40
|
|
|
private $sprint; |
41
|
|
|
private $planning_id; |
42
|
|
|
|
43
|
|
|
public function testItEditSoloCardLabel() { |
44
|
|
|
$put = json_encode(array( |
45
|
|
|
"label" => "Whatever", |
46
|
|
|
"column_id" => null, |
47
|
|
|
"values" => array() |
48
|
|
|
)); |
49
|
|
|
try { |
50
|
|
|
$response = $this->getResponse($this->client->put('cards/'.$this->planning_id.'_'.$this->story['id'], null, $put)); |
51
|
|
|
$this->assertEquals($response->getStatusCode(), 200); |
52
|
|
|
} catch (Guzzle\Http\Exception\BadResponseException $exception) { |
53
|
|
|
echo $exception->getRequest(); |
54
|
|
|
echo $exception->getResponse()->getBody(true); |
55
|
|
|
die(PHP_EOL); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function setUp() { |
60
|
|
|
parent::setUp(); |
61
|
|
|
$this->project_id = REST_TestDataBuilder::PROJECT_PRIVATE_MEMBER_ID; |
62
|
|
|
$this->tracker_test_helper = new Test\Rest\Tracker\TrackerFactory( |
63
|
|
|
$this->client, |
64
|
|
|
$this->rest_request, |
65
|
|
|
$this->project_id, |
66
|
|
|
REST_TestDataBuilder::TEST_USER_1_NAME |
67
|
|
|
); |
68
|
|
|
|
69
|
|
|
try { |
70
|
|
|
$this->story = $this->createStory('Story 1'); |
71
|
|
|
$this->task = $this->createTask('Task 1'); |
72
|
|
|
$this->sprint = $this->createSprint("Sprint 1"); |
73
|
|
|
$this->planning_id = $this->getSprintPlanningId(); |
74
|
|
|
} catch (Guzzle\Http\Exception\BadResponseException $exception) { |
75
|
|
|
echo $exception->getRequest(); |
76
|
|
|
echo $exception->getResponse()->getBody(true); |
77
|
|
|
die(PHP_EOL); |
|
|
|
|
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
private function createStory($summary) { |
82
|
|
|
$tracker = $this->tracker_test_helper->getTrackerRest('story'); |
83
|
|
|
return $tracker->createArtifact( |
84
|
|
|
array( |
85
|
|
|
$tracker->getSubmitTextValue('I want to', $summary), |
86
|
|
|
$tracker->getSubmitListValue('Status', 'To be done'), |
87
|
|
|
) |
88
|
|
|
); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
private function createTask($summary) { |
92
|
|
|
$tracker = $this->tracker_test_helper->getTrackerRest('task'); |
93
|
|
|
return $tracker->createArtifact( |
94
|
|
|
array( |
95
|
|
|
$tracker->getSubmitTextValue('Summary', $summary), |
96
|
|
|
$tracker->getSubmitListValue('Status', 'To be done'), |
97
|
|
|
) |
98
|
|
|
); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
|
102
|
|
|
private function createSprint($name) { |
103
|
|
|
$tracker = $this->tracker_test_helper->getTrackerRest('sprint'); |
104
|
|
|
return $tracker->createArtifact( |
105
|
|
|
array( |
106
|
|
|
$tracker->getSubmitTextValue('Name', $name), |
107
|
|
|
$tracker->getSubmitListValue('Status', 'Current'), |
108
|
|
|
) |
109
|
|
|
); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
private function getSprintPlanningId() { |
113
|
|
|
$project_plannings = $this->getResponse($this->client->get("projects/{$this->project_id}/plannings"))->json(); |
114
|
|
|
foreach ($project_plannings as $planning) { |
115
|
|
|
if ($planning['label'] == 'Sprint Planning') { |
116
|
|
|
return $planning['id']; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
private function getResponse($request) { |
122
|
|
|
return $this->getResponseByToken( |
123
|
|
|
$this->getTokenForUserName(REST_TestDataBuilder::TEST_USER_1_NAME), |
124
|
|
|
$request |
125
|
|
|
); |
126
|
|
|
} |
127
|
|
|
} |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.