@@ -46,33 +46,27 @@ public function testPostSessionsWithNoJsonReturnsError400()
46
46
$ this ->jsonRequest ('post ' , '/api/v2/sessions ' );
47
47
48
48
$ this ->assertHttpBadRequest ();
49
- $ this ->assertJsonResponseContentEquals (
50
- [
51
- 'message ' => 'Empty JSON data ' ,
52
- ]
53
- );
49
+ $ data = $ this ->getDecodedJsonResponseContent ();
50
+ $ this ->assertStringContainsString ('Invalid JSON: ' , $ data ['message ' ]);
54
51
}
55
52
56
53
public function testPostSessionsWithInvalidJsonWithJsonContentTypeReturnsError400 ()
57
54
{
58
55
$ this ->jsonRequest ('post ' , '/api/v2/sessions ' , [], [], [], 'Here be dragons, but no JSON. ' );
59
56
60
57
$ 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 ' ]);
66
60
}
67
61
68
- public function testPostSessionsWithValidEmptyJsonWithOtherTypeReturnsError400 ()
62
+ public function testPostSessionsWithValidEmptyJsonWithOtherTypeReturnsError422 ()
69
63
{
70
64
self ::getClient ()->request ('post ' , '/api/v2/sessions ' , [], [], ['CONTENT_TYPE ' => 'application/xml ' ], '[] ' );
71
65
72
- $ this ->assertHttpBadRequest ();
66
+ $ this ->assertHttpUnprocessableEntity ();
73
67
$ this ->assertJsonResponseContentEquals (
74
68
[
75
- 'message ' => ' Incomplete credentials ' ,
69
+ 'message ' => " loginName: This value should not be blank. \n password: This value should not be blank. " ,
76
70
]
77
71
);
78
72
}
@@ -84,7 +78,7 @@ public static function incompleteCredentialsDataProvider(): array
84
78
{
85
79
return [
86
80
'neither login_name nor password ' => ['{} ' ],
87
- 'login_name, but no password ' => [
'{"login_name ": "[email protected] "} ' ],
81
+ 'login_name, but no password ' => [
'{"loginName ": "[email protected] "} ' ],
88
82
'password, but no login_name ' => ['{"password": "t67809oibuzfq2qg3"} ' ],
89
83
];
90
84
}
@@ -96,12 +90,9 @@ public function testPostSessionsWithValidIncompleteJsonReturnsError400(string $j
96
90
{
97
91
$ this ->jsonRequest ('post ' , '/api/v2/sessions ' , [], [], [], $ jsonData );
98
92
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 ' ]);
105
96
}
106
97
107
98
public function testPostSessionsWithInvalidCredentialsReturnsNotAuthorized ()
@@ -110,7 +101,7 @@ public function testPostSessionsWithInvalidCredentialsReturnsNotAuthorized()
110
101
111
102
$ loginName = 'john.doe ' ;
112
103
$ password = 'a sandwich and a cup of coffee ' ;
113
- $ jsonData = ['login_name ' => $ loginName , 'password ' => $ password ];
104
+ $ jsonData = ['loginName ' => $ loginName , 'password ' => $ password ];
114
105
115
106
$ this ->jsonRequest ('post ' , '/api/v2/sessions ' , [], [], [], json_encode ($ jsonData ));
116
107
@@ -128,7 +119,7 @@ public function testPostSessionsActionWithValidCredentialsReturnsCreatedHttpStat
128
119
129
120
$ loginName = 'john.doe ' ;
130
121
$ password = 'Bazinga! ' ;
131
- $ jsonData = ['login_name ' => $ loginName , 'password ' => $ password ];
122
+ $ jsonData = ['loginName ' => $ loginName , 'password ' => $ password ];
132
123
133
124
$ this ->jsonRequest ('post ' , '/api/v2/sessions ' , [], [], [], json_encode ($ jsonData ));
134
125
@@ -139,7 +130,7 @@ public function testPostSessionsActionWithValidCredentialsCreatesToken()
139
130
{
140
131
$ administratorId = 1 ;
141
132
$ this ->loadFixtures ([AdministratorFixture::class, AdministratorTokenFixture::class]);
142
- $ jsonData = ['login_name ' => 'john.doe ' , 'password ' => 'Bazinga! ' ];
133
+ $ jsonData = ['loginName ' => 'john.doe ' , 'password ' => 'Bazinga! ' ];
143
134
144
135
$ this ->jsonRequest ('post ' , '/api/v2/sessions ' , [], [], [], json_encode ($ jsonData ));
145
136
0 commit comments