18
18
*/
19
19
class JsonLoginTest extends AbstractWebTestCase
20
20
{
21
- public function testDefaultJsonLoginSuccess ()
21
+ /**
22
+ * @dataProvider provideSecuritySystems
23
+ */
24
+ public function testDefaultJsonLoginSuccess (array $ options )
22
25
{
23
- $ client = $ this ->createClient (['test_case ' => 'JsonLogin ' , 'root_config ' => 'config.yml ' ]);
26
+ $ client = $ this ->createClient ($ options + ['test_case ' => 'JsonLogin ' , 'root_config ' => 'config.yml ' ]);
24
27
$ client ->request ('POST ' , '/chk ' , [], [], ['CONTENT_TYPE ' => 'application/json ' ], '{"user": {"login": "dunglas", "password": "foo"}} ' );
25
28
$ response = $ client ->getResponse ();
26
29
@@ -29,9 +32,12 @@ public function testDefaultJsonLoginSuccess()
29
32
$ this ->assertSame (['message ' => 'Welcome @dunglas! ' ], json_decode ($ response ->getContent (), true ));
30
33
}
31
34
32
- public function testDefaultJsonLoginFailure ()
35
+ /**
36
+ * @dataProvider provideSecuritySystems
37
+ */
38
+ public function testDefaultJsonLoginFailure (array $ options )
33
39
{
34
- $ client = $ this ->createClient (['test_case ' => 'JsonLogin ' , 'root_config ' => 'config.yml ' ]);
40
+ $ client = $ this ->createClient ($ options + ['test_case ' => 'JsonLogin ' , 'root_config ' => 'config.yml ' ]);
35
41
$ client ->request ('POST ' , '/chk ' , [], [], ['CONTENT_TYPE ' => 'application/json ' ], '{"user": {"login": "dunglas", "password": "bad"}} ' );
36
42
$ response = $ client ->getResponse ();
37
43
@@ -40,9 +46,12 @@ public function testDefaultJsonLoginFailure()
40
46
$ this ->assertSame (['error ' => 'Invalid credentials. ' ], json_decode ($ response ->getContent (), true ));
41
47
}
42
48
43
- public function testCustomJsonLoginSuccess ()
49
+ /**
50
+ * @dataProvider provideSecuritySystems
51
+ */
52
+ public function testCustomJsonLoginSuccess (array $ options )
44
53
{
45
- $ client = $ this ->createClient (['test_case ' => 'JsonLogin ' , 'root_config ' => 'custom_handlers.yml ' ]);
54
+ $ client = $ this ->createClient ($ options + ['test_case ' => 'JsonLogin ' , 'root_config ' => 'custom_handlers.yml ' ]);
46
55
$ client ->request ('POST ' , '/chk ' , [], [], ['CONTENT_TYPE ' => 'application/json ' ], '{"user": {"login": "dunglas", "password": "foo"}} ' );
47
56
$ response = $ client ->getResponse ();
48
57
@@ -51,9 +60,12 @@ public function testCustomJsonLoginSuccess()
51
60
$ this ->assertSame (['message ' => 'Good game @dunglas! ' ], json_decode ($ response ->getContent (), true ));
52
61
}
53
62
54
- public function testCustomJsonLoginFailure ()
63
+ /**
64
+ * @dataProvider provideSecuritySystems
65
+ */
66
+ public function testCustomJsonLoginFailure (array $ options )
55
67
{
56
- $ client = $ this ->createClient (['test_case ' => 'JsonLogin ' , 'root_config ' => 'custom_handlers.yml ' ]);
68
+ $ client = $ this ->createClient ($ options + ['test_case ' => 'JsonLogin ' , 'root_config ' => 'custom_handlers.yml ' ]);
57
69
$ client ->request ('POST ' , '/chk ' , [], [], ['CONTENT_TYPE ' => 'application/json ' ], '{"user": {"login": "dunglas", "password": "bad"}} ' );
58
70
$ response = $ client ->getResponse ();
59
71
@@ -62,9 +74,12 @@ public function testCustomJsonLoginFailure()
62
74
$ this ->assertSame (['message ' => 'Something went wrong ' ], json_decode ($ response ->getContent (), true ));
63
75
}
64
76
65
- public function testDefaultJsonLoginBadRequest ()
77
+ /**
78
+ * @dataProvider provideSecuritySystems
79
+ */
80
+ public function testDefaultJsonLoginBadRequest (array $ options )
66
81
{
67
- $ client = $ this ->createClient (['test_case ' => 'JsonLogin ' , 'root_config ' => 'config.yml ' ]);
82
+ $ client = $ this ->createClient ($ options + ['test_case ' => 'JsonLogin ' , 'root_config ' => 'config.yml ' ]);
68
83
$ client ->request ('POST ' , '/chk ' , [], [], ['CONTENT_TYPE ' => 'application/json ' ], 'Not a json content ' );
69
84
$ response = $ client ->getResponse ();
70
85
0 commit comments