Skip to content

Commit b079052

Browse files
committed
Use PUT instead of PATCH in Attachment::update()
1 parent 23ccecc commit b079052

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Redmine/Api/Attachment.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,17 @@ public function show($id)
6464
*/
6565
final public function update(int $id, array $params): bool
6666
{
67+
// we are using `PUT` instead of `PATCH`
68+
// @see https://github.com/kbsali/php-redmine-api/pull/395#issuecomment-2004089154
6769
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeJsonRequest(
68-
'PATCH',
70+
'PUT',
6971
'/attachments/' . $id . '.json',
7072
JsonSerializer::createFromArray(['attachment' => $params])->getEncoded()
7173
));
7274

73-
// if ($this->lastResponse->getStatusCode() !== 204) {
74-
// throw UnexpectedResponseException::create($this->lastResponse);
75-
// }
75+
if ($this->lastResponse->getStatusCode() !== 204) {
76+
throw UnexpectedResponseException::create($this->lastResponse);
77+
}
7678

7779
return true;
7880
}

tests/Unit/Api/Attachment/UpdateTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testUpdateReturnsCorrectResponse($id, array $params, $expectedPa
2121
$client = AssertingHttpClient::create(
2222
$this,
2323
[
24-
'PATCH',
24+
'PUT',
2525
$expectedPath,
2626
'application/json',
2727
$expectedContent,
@@ -59,7 +59,7 @@ public function testUpdateThrowsUnexpectedResponseException()
5959
$client = AssertingHttpClient::create(
6060
$this,
6161
[
62-
'PATCH',
62+
'PUT',
6363
'/attachments/5.json',
6464
'application/json',
6565
'{"attachment":[]}',

0 commit comments

Comments
 (0)