@@ -56,34 +56,20 @@ public function testInit()
56
56
public function testNonceOnExcludedControllers ()
57
57
{
58
58
//when CSPBackend.useNonce is true, it should only apply to controllers
59
- //with the extension applied. By default, this is page controller
59
+ //with the extension applied. By default, this is root controller
60
60
CSPBackend::setUsesNonce (true );
61
61
$ page = new Page ();
62
62
$ controller = new PageController ($ page );
63
63
$ extension = new ControllerCSPExtension ();
64
64
65
65
$ extension ->setOwner ($ controller );
66
66
67
- //useNonce is set but only applies on the PageController.
68
- //let's check Security controller for logins: it should be absent
67
+ //let's check Security controller for logins: it should be there
69
68
$ secController = new Security ();
70
- $ this ->expectException ('BadMethodCallException ' );
71
- $ this ->assertNull ($ secController ->getNonce ());
69
+ $ this ->assertNotNull ($ secController ->getNonce ());
72
70
73
71
//also check CMS-level controllers
74
72
$ cmsController = new LeftAndMain ();
75
- $ this ->expectException ('BadMethodCallException ' );
76
- $ this ->assertNull ($ secController ->getNonce ());
77
-
78
- //now apply the extension, getNonce should not be null
79
- $ extension2 = new ControllerCSPExtension ();
80
-
81
- $ extension2 ->setOwner ($ secController );
82
73
$ this ->assertNotNull ($ secController ->getNonce ());
83
-
84
- $ extension3 = new ControllerCSPExtension ();
85
-
86
- $ extension3 ->setOwner ($ cmsController );
87
- $ this ->assertNotNull ($ cmsController ->getNonce ());
88
74
}
89
75
}
0 commit comments