File tree Expand file tree Collapse file tree 3 files changed +17
-15
lines changed Expand file tree Collapse file tree 3 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -202,9 +202,11 @@ public function update($id, array $params)
202
202
*
203
203
* @param string|int $projectIdentifier project id or identifier
204
204
*
205
- * @return string empty string
205
+ * @throws InvalidArgumentException if $projectIdentifier is not provided as int or string
206
+ *
207
+ * @return bool true if the request was successful
206
208
*/
207
- public function close ($ projectIdentifier ): string
209
+ public function close ($ projectIdentifier ): bool
208
210
{
209
211
if (! is_int ($ projectIdentifier ) && ! is_string ($ projectIdentifier )) {
210
212
throw new InvalidArgumentException (sprintf (
@@ -213,10 +215,14 @@ public function close($projectIdentifier): string
213
215
));
214
216
}
215
217
216
- return $ this ->put (
218
+ $ this ->put (
217
219
'/projects/ ' . strval ($ projectIdentifier ) . '/close.xml ' ,
218
220
''
219
221
);
222
+
223
+ $ lastResponse = $ this ->getLastResponse ();
224
+
225
+ return ($ lastResponse ->getStatusCode () === 204 );
220
226
}
221
227
222
228
/**
Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ public function testInteractionWithProject(RedmineVersion $redmineVersion): void
20
20
21
21
/** @var Project */
22
22
$ api = $ client ->getApi ('project ' );
23
- $ now = new DateTimeImmutable ();
24
23
25
24
// Create project
26
25
$ projectName = 'test project ' ;
@@ -41,8 +40,7 @@ public function testInteractionWithProject(RedmineVersion $redmineVersion): void
41
40
$ this ->assertSame ('1 ' , $ projectData ['status ' ], $ projectDataJson );
42
41
43
42
// Close project
44
- $ result = $ api ->close ($ projectIdentifier );
45
- $ this ->assertSame ('' , $ result );
43
+ $ this ->assertTrue ($ api ->close ($ projectIdentifier ));
46
44
47
45
// Read single project
48
46
$ projectDetails = $ api ->show ($ projectIdentifier );
Original file line number Diff line number Diff line change @@ -24,19 +24,17 @@ public function testCloseReturnsResponse()
24
24
$ this ->assertSame ('/projects/5/close.xml ' , $ path );
25
25
$ this ->assertSame ('' , $ body );
26
26
27
- return $ this ->createConfiguredMock (
28
- Response::class,
29
- [
30
- 'getContentType ' => 'application/xml ' ,
31
- 'getBody ' => '' ,
32
- ]
33
- );
27
+ return $ this ->createConfiguredMock (Response::class, [
28
+ 'getStatusCode ' => 204 ,
29
+ 'getContentType ' => 'application/xml ' ,
30
+ 'getBody ' => '' ,
31
+ ]);
34
32
})
35
33
;
36
34
37
35
$ api = new Project ($ client );
38
36
39
- $ this ->assertSame ( '' , $ api ->close (5 ));
37
+ $ this ->assertTrue ( $ api ->close (5 ));
40
38
}
41
39
42
40
public function testCloseWithoutIntOrStringThrowsInvalidArgumentException ()
@@ -48,7 +46,7 @@ public function testCloseWithoutIntOrStringThrowsInvalidArgumentException()
48
46
$ this ->expectException (InvalidArgumentException::class);
49
47
$ this ->expectExceptionMessage ('Redmine\Api\Project::close(): Argument #1 ($projectIdentifier) must be of type int or string ' );
50
48
51
- // Perform the tests
49
+ // provide a wrong project identifier
52
50
$ api ->close (true );
53
51
}
54
52
}
You can’t perform that action at this time.
0 commit comments