@@ -78,17 +78,27 @@ protected function get_controller()
78
78
public function controller_data ()
79
79
{
80
80
return array (
81
+ array (
82
+ 'enable ' ,
83
+ false ,
84
+ 200 ,
85
+ 0 ,
86
+ ),
81
87
array (
82
88
'enable ' ,
83
89
true ,
84
- true , // use ajax to bypass redirects in testing
85
90
200 ,
86
91
0 ,
87
92
),
88
93
array (
89
94
'disable ' ,
90
95
true ,
91
- true , // use ajax to bypass redirects in testing
96
+ 200 ,
97
+ 1 ,
98
+ ),
99
+ array (
100
+ 'disable ' ,
101
+ false ,
92
102
200 ,
93
103
1 ,
94
104
),
@@ -100,12 +110,13 @@ public function controller_data()
100
110
*
101
111
* @dataProvider controller_data
102
112
*/
103
- public function test_controller ($ action , $ is_admin , $ is_ajax , $ status_code , $ cookie_time )
113
+ public function test_controller ($ action , $ is_ajax , $ status_code , $ cookie_time )
104
114
{
115
+ // User is an admin
105
116
$ this ->auth ->expects ($ this ->any ())
106
117
->method ('acl_get ' )
107
118
->with ($ this ->stringContains ('a_ ' ), $ this ->anything ())
108
- ->will ($ this ->returnValue ($ is_admin ));
119
+ ->will ($ this ->returnValue (true ));
109
120
110
121
$ this ->request ->expects ($ this ->any ())
111
122
->method ('is_ajax ' )
@@ -115,8 +126,13 @@ public function test_controller($action, $is_admin, $is_ajax, $status_code, $coo
115
126
->method ('set_cookie ' )
116
127
->with ('phpbb_ads_visual_demo ' , $ this ->anything (), $ cookie_time );
117
128
118
- $ controller = $ this ->get_controller ();
129
+ // If non-ajax redirect is encountered, in testing it will trigger error
130
+ if (!$ is_ajax )
131
+ {
132
+ $ this ->setExpectedTriggerError (E_USER_ERROR );
133
+ }
119
134
135
+ $ controller = $ this ->get_controller ();
120
136
$ response = $ controller ->handle ($ action );
121
137
$ this ->assertInstanceOf ('\Symfony\Component\HttpFoundation\JsonResponse ' , $ response );
122
138
$ this ->assertEquals ($ status_code , $ response ->getStatusCode ());
@@ -132,13 +148,11 @@ public function controller_fails_data()
132
148
return array (
133
149
array (
134
150
'enable ' ,
135
- false , // is admin
136
151
403 ,
137
152
'NO_AUTH_OPERATION ' ,
138
153
),
139
154
array (
140
155
'disable ' ,
141
- false , // is admin
142
156
403 ,
143
157
'NO_AUTH_OPERATION ' ,
144
158
),
@@ -150,12 +164,13 @@ public function controller_fails_data()
150
164
*
151
165
* @dataProvider controller_fails_data
152
166
*/
153
- public function test_controller_fails ($ action , $ is_admin , $ status_code , $ message )
167
+ public function test_controller_fails ($ action , $ status_code , $ message )
154
168
{
169
+ // User is not an admin
155
170
$ this ->auth ->expects ($ this ->any ())
156
171
->method ('acl_get ' )
157
172
->with ($ this ->stringContains ('a_ ' ), $ this ->anything ())
158
- ->will ($ this ->returnValue ($ is_admin ));
173
+ ->will ($ this ->returnValue (false ));
159
174
160
175
$ controller = $ this ->get_controller ();
161
176
0 commit comments