File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace spec \Phpro \ApiProblem \Http ;
6+
7+ use Phpro \ApiProblem \Http \BadRequestProblem ;
8+ use Phpro \ApiProblem \Http \HttpApiProblem ;
9+ use PhpSpec \ObjectBehavior ;
10+
11+ class BadRequestProblemSpec extends ObjectBehavior
12+ {
13+ public function let (): void
14+ {
15+ $ this ->beConstructedWith ('a reason ' );
16+ }
17+
18+ public function it_is_initializable (): void
19+ {
20+ $ this ->shouldHaveType (BadRequestProblem::class);
21+ }
22+
23+ public function it_is_an_http_api_problem (): void
24+ {
25+ $ this ->shouldHaveType (HttpApiProblem::class);
26+ }
27+
28+ public function it_can_parse_to_array (): void
29+ {
30+ $ this ->toArray ()->shouldBe ([
31+ 'status ' => 400 ,
32+ 'type ' => HttpApiProblem::TYPE_HTTP_RFC ,
33+ 'title ' => HttpApiProblem::getTitleForStatusCode (400 ),
34+ 'detail ' => 'a reason ' ,
35+ ]);
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Phpro \ApiProblem \Http ;
6+
7+ class BadRequestProblem extends HttpApiProblem
8+ {
9+ public function __construct (string $ detail )
10+ {
11+ parent ::__construct (400 , [
12+ 'detail ' => $ detail ,
13+ ]);
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments