This repository was archived by the owner on Nov 27, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
src/Acme/DemoBundle/Tests/Controller Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -14,4 +14,32 @@ public function testIndex()
14
14
15
15
$ this ->assertGreaterThan (0 , $ crawler ->filter ('html:contains("Hello Fabien") ' )->count ());
16
16
}
17
+
18
+ public function testSecureSection ()
19
+ {
20
+ $ client = static ::createClient ();
21
+
22
+ // goes to the secure page
23
+ $ crawler = $ client ->request ('GET ' , '/demo/secured/hello/World ' );
24
+
25
+ // redirects to the login page
26
+ $ crawler = $ client ->followRedirect ();
27
+
28
+ // submits the login form
29
+ $ form = $ crawler ->selectButton ('Login ' )->form (array ('_username ' => 'admin ' , '_password ' => 'adminpass ' ));
30
+ $ client ->submit ($ form );
31
+
32
+ // redirect to the original page (but now authenticated)
33
+ $ crawler = $ client ->followRedirect ();
34
+
35
+ // check that the page is the right one
36
+ $ this ->assertCount (1 , $ crawler ->filter ('h1.title:contains("Hello World!") ' ));
37
+
38
+ // click on the secure link
39
+ $ link = $ crawler ->selectLink ('Hello resource secured ' )->link ();
40
+ $ crawler = $ client ->click ($ link );
41
+
42
+ // check that the page is the right one
43
+ $ this ->assertCount (1 , $ crawler ->filter ('h1.title:contains("secured for Admins only!") ' ));
44
+ }
17
45
}
You can’t perform that action at this time.
0 commit comments