File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
tests/Unit/Api/Attachment Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ public function show($id)
6363 *
6464 * @return true if the request was successful
6565 */
66- public function update (int $ id , array $ params ): bool
66+ final public function update (int $ id , array $ params ): bool
6767 {
6868 $ this ->lastResponse = $ this ->getHttpClient ()->request (HttpFactory::makeJsonRequest (
6969 'PATCH ' ,
Original file line number Diff line number Diff line change 66use PHPUnit \Framework \Attributes \DataProvider ;
77use PHPUnit \Framework \TestCase ;
88use Redmine \Api \Attachment ;
9+ use Redmine \Exception \UnexpectedResponseException ;
910use Redmine \Tests \Fixtures \AssertingHttpClient ;
1011
1112#[CoversClass(Attachment::class)]
@@ -52,4 +53,27 @@ public static function getUpdateData(): array
5253 ],
5354 ];
5455 }
56+
57+ public function testUpdateThrowsUnexpectedResponseException ()
58+ {
59+ $ client = AssertingHttpClient::create (
60+ $ this ,
61+ [
62+ 'PATCH ' ,
63+ '/attachments/5.json ' ,
64+ 'application/json ' ,
65+ '{"attachment":[]} ' ,
66+ 403 ,
67+ '' ,
68+ '' ,
69+ ]
70+ );
71+
72+ $ api = new Attachment ($ client );
73+
74+ $ this ->expectException (UnexpectedResponseException::class);
75+ $ this ->expectExceptionMessage ('The Redmine server replied with an unexpected response. ' );
76+
77+ $ api ->update (5 , []);
78+ }
5579}
You can’t perform that action at this time.
0 commit comments