@@ -46,33 +46,27 @@ public function testPostSessionsWithNoJsonReturnsError400()
4646 $ this ->jsonRequest ('post ' , '/api/v2/sessions ' );
4747
4848 $ this ->assertHttpBadRequest ();
49- $ this ->assertJsonResponseContentEquals (
50- [
51- 'message ' => 'Empty JSON data ' ,
52- ]
53- );
49+ $ data = $ this ->getDecodedJsonResponseContent ();
50+ $ this ->assertStringContainsString ('Invalid JSON: ' , $ data ['message ' ]);
5451 }
5552
5653 public function testPostSessionsWithInvalidJsonWithJsonContentTypeReturnsError400 ()
5754 {
5855 $ this ->jsonRequest ('post ' , '/api/v2/sessions ' , [], [], [], 'Here be dragons, but no JSON. ' );
5956
6057 $ this ->assertHttpBadRequest ();
61- $ this ->assertJsonResponseContentEquals (
62- [
63- 'message ' => 'Could not decode request body. ' ,
64- ]
65- );
58+ $ data = $ this ->getDecodedJsonResponseContent ();
59+ $ this ->assertStringContainsString ('Invalid JSON: ' , $ data ['message ' ]);
6660 }
6761
68- public function testPostSessionsWithValidEmptyJsonWithOtherTypeReturnsError400 ()
62+ public function testPostSessionsWithValidEmptyJsonWithOtherTypeReturnsError422 ()
6963 {
7064 self ::getClient ()->request ('post ' , '/api/v2/sessions ' , [], [], ['CONTENT_TYPE ' => 'application/xml ' ], '[] ' );
7165
72- $ this ->assertHttpBadRequest ();
66+ $ this ->assertHttpUnprocessableEntity ();
7367 $ this ->assertJsonResponseContentEquals (
7468 [
75- 'message ' => ' Incomplete credentials ' ,
69+ 'message ' => " loginName: This value should not be blank. \n password: This value should not be blank. " ,
7670 ]
7771 );
7872 }
@@ -84,7 +78,7 @@ public static function incompleteCredentialsDataProvider(): array
8478 {
8579 return [
8680 'neither login_name nor password ' => ['{} ' ],
87- 'login_name, but no password ' => [
'{"login_name ": "[email protected] "} ' ],
81+ 'login_name, but no password ' => [
'{"loginName ": "[email protected] "} ' ],
8882 'password, but no login_name ' => ['{"password": "t67809oibuzfq2qg3"} ' ],
8983 ];
9084 }
@@ -96,12 +90,9 @@ public function testPostSessionsWithValidIncompleteJsonReturnsError400(string $j
9690 {
9791 $ this ->jsonRequest ('post ' , '/api/v2/sessions ' , [], [], [], $ jsonData );
9892
99- $ this ->assertHttpBadRequest ();
100- $ this ->assertJsonResponseContentEquals (
101- [
102- 'message ' => 'Incomplete credentials ' ,
103- ]
104- );
93+ $ this ->assertHttpUnprocessableEntity ();
94+ $ data = $ this ->getDecodedJsonResponseContent ();
95+ $ this ->assertStringContainsString ('This value should not be blank ' , $ data ['message ' ]);
10596 }
10697
10798 public function testPostSessionsWithInvalidCredentialsReturnsNotAuthorized ()
@@ -110,7 +101,7 @@ public function testPostSessionsWithInvalidCredentialsReturnsNotAuthorized()
110101
111102 $ loginName = 'john.doe ' ;
112103 $ password = 'a sandwich and a cup of coffee ' ;
113- $ jsonData = ['login_name ' => $ loginName , 'password ' => $ password ];
104+ $ jsonData = ['loginName ' => $ loginName , 'password ' => $ password ];
114105
115106 $ this ->jsonRequest ('post ' , '/api/v2/sessions ' , [], [], [], json_encode ($ jsonData ));
116107
@@ -128,7 +119,7 @@ public function testPostSessionsActionWithValidCredentialsReturnsCreatedHttpStat
128119
129120 $ loginName = 'john.doe ' ;
130121 $ password = 'Bazinga! ' ;
131- $ jsonData = ['login_name ' => $ loginName , 'password ' => $ password ];
122+ $ jsonData = ['loginName ' => $ loginName , 'password ' => $ password ];
132123
133124 $ this ->jsonRequest ('post ' , '/api/v2/sessions ' , [], [], [], json_encode ($ jsonData ));
134125
@@ -139,7 +130,7 @@ public function testPostSessionsActionWithValidCredentialsCreatesToken()
139130 {
140131 $ administratorId = 1 ;
141132 $ this ->loadFixtures ([AdministratorFixture::class, AdministratorTokenFixture::class]);
142- $ jsonData = ['login_name ' => 'john.doe ' , 'password ' => 'Bazinga! ' ];
133+ $ jsonData = ['loginName ' => 'john.doe ' , 'password ' => 'Bazinga! ' ];
143134
144135 $ this ->jsonRequest ('post ' , '/api/v2/sessions ' , [], [], [], json_encode ($ jsonData ));
145136
0 commit comments