@@ -15,6 +15,9 @@ class admin_input_test extends \phpbb_database_test_case
1515 /** @var bool A return value for check_form_key() */
1616 public static $ valid_form = true ;
1717
18+ /** @var \phpbb\controller\helper */
19+ protected $ controller_helper ;
20+
1821 /** @var \phpbb\user */
1922 protected $ user ;
2023
@@ -60,6 +63,9 @@ protected function setUp(): void
6063
6164 // Load/Mock classes required by the controller class
6265 $ this ->language = new \phpbb \language \language (new \phpbb \language \language_file_loader ($ phpbb_root_path , $ phpEx ));
66+ $ this ->controller_helper = $ this ->getMockBuilder ('\phpbb\controller\helper ' )
67+ ->disableOriginalConstructor ()
68+ ->getMock ();
6369 $ this ->user = $ user = new \phpbb \user ($ this ->language , '\phpbb\datetime ' );
6470 $ this ->user ->timezone = new \DateTimeZone ('UTC ' );
6571 $ avatar_helper = $ this ->getMockBuilder ('\phpbb\avatar\helper ' )
@@ -92,6 +98,7 @@ protected function setUp(): void
9298 public function get_input_controller ()
9399 {
94100 $ input = new \phpbb \ads \controller \admin_input (
101+ $ this ->controller_helper ,
95102 $ this ->user ,
96103 $ this ->user_loader ,
97104 $ this ->language ,
@@ -210,24 +217,15 @@ public function test_banner_upload($can_create_directory, $can_move_file, $is_aj
210217 {
211218 $ input_controller = $ this ->get_input_controller ();
212219
213- $ create_storage_dir = $ this ->banner ->expects (self ::once ())
214- ->method ('create_storage_dir ' );
215- if (!$ can_create_directory )
220+ $ upload = $ this ->banner ->expects (self ::once ())
221+ ->method ('upload ' );
222+ if (!$ can_move_file )
216223 {
217- $ create_storage_dir ->willThrowException (new \phpbb \exception \runtime_exception ('CANNOT_CREATE_DIRECTORY ' ));
224+ $ upload ->willThrowException (new \phpbb \exception \runtime_exception ('FILE_MOVE_UNSUCCESSFUL ' ));
218225 }
219226 else
220227 {
221- $ upload = $ this ->banner ->expects (self ::once ())
222- ->method ('upload ' );
223- if (!$ can_move_file )
224- {
225- $ upload ->willThrowException (new \phpbb \exception \runtime_exception ('FILE_MOVE_UNSUCCESSFUL ' ));
226- }
227- else
228- {
229- $ upload ->willReturn ('abcdef.jpg ' );
230- }
228+ $ upload ->willReturn ('abcdef.jpg ' );
231229 }
232230
233231 if (!$ can_create_directory || !$ can_move_file )
@@ -236,6 +234,9 @@ public function test_banner_upload($can_create_directory, $can_move_file, $is_aj
236234 ->method ('remove ' );
237235 }
238236
237+ $ this ->controller_helper ->method ('route ' )
238+ ->willReturn ('/images/phpbb_ads/abcdef.jpg ' );
239+
239240 $ this ->request ->expects (self ::once ())
240241 ->method ('is_ajax ' )
241242 ->willReturn ($ is_ajax );
0 commit comments