File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,21 @@ public function assertSuccessfulPrecognition()
131131 return $ this ;
132132 }
133133
134+ /**
135+ * Assert that the response is a client error.
136+ *
137+ * @return $this
138+ */
139+ public function assertClientError ()
140+ {
141+ PHPUnit::withResponse ($ this )->assertTrue (
142+ $ this ->isClientError (),
143+ $ this ->statusMessageWithDetails ('>=400, < 500 ' , $ this ->getStatusCode ())
144+ );
145+
146+ return $ this ;
147+ }
148+
134149 /**
135150 * Assert that the response is a server error.
136151 *
Original file line number Diff line number Diff line change @@ -1086,6 +1086,18 @@ public function testAssertUnprocessable()
10861086 $ response ->assertUnprocessable ();
10871087 }
10881088
1089+ public function testAssertClientError ()
1090+ {
1091+ $ statusCode = 400 ;
1092+
1093+ $ baseResponse = tap (new Response , function ($ response ) use ($ statusCode ) {
1094+ $ response ->setStatusCode ($ statusCode );
1095+ });
1096+
1097+ $ response = TestResponse::fromBaseResponse ($ baseResponse );
1098+ $ response ->assertClientError ();
1099+ }
1100+
10891101 public function testAssertServerError ()
10901102 {
10911103 $ statusCode = 500 ;
You can’t perform that action at this time.
0 commit comments