@@ -57,48 +57,47 @@ public function controller_test_data()
5757 public function test_controller ($ idea_id , $ mode , $ callback , $ is_ajax , $ authorised , $ expected , $ status_code , $ additional_data = [])
5858 {
5959 // mock some basic idea data
60- $ this ->ideas ->expects ($ this ->any ())
60+ $ this ->ideas ->expects ($ this ->once ())
6161 ->method ('get_idea ' )
62- ->will ($ this ->returnValue (
63- array_merge (array (
64- 'idea_id ' => $ idea_id ,
65- 'idea_author ' => 2 ,
66- 'idea_status ' => \phpbb \ideas \factory \ideas::$ statuses ['NEW ' ]
67- ), $ additional_data ))
62+ ->willReturn (array_merge (array (
63+ 'idea_id ' => $ idea_id ,
64+ 'idea_author ' => 2 ,
65+ 'idea_status ' => \phpbb \ideas \factory \ideas::$ statuses ['NEW ' ]
66+ ), $ additional_data )
6867 );
6968
7069 // mock a result from each method called by the idea controller
7170 if ($ expected === 'true ' )
7271 {
7372 $ this ->ideas ->expects ($ this ->once ())
7473 ->method (($ callback ))
75- ->will ( $ this -> returnValue ( $ authorised) );
74+ ->willReturn ( $ authorised );
7675 }
7776
7877 // set if using ajax or not
79- $ this ->request ->expects ($ this ->any ())
78+ $ this ->request ->expects ($ is_ajax ? $ this ->once () : $ this -> never ())
8079 ->method ('is_ajax ' )
81- ->will ( $ this -> returnValue ( $ is_ajax) );
80+ ->willReturn ( $ is_ajax );
8281
8382 // mock some useful variables requested by the idea controller
84- $ this ->request ->expects ($ this ->any ())
83+ $ this ->request ->expects ($ this ->atLeastOnce ())
8584 ->method ('variable ' )
8685 ->with ($ this ->anything ())
87- ->will ( $ this -> returnValueMap (array (
86+ ->willReturnMap (array (
8887 array ('mode ' , '' , false , \phpbb \request \request_interface::REQUEST , $ mode ),
8988 array ('hash ' , '' , false , \phpbb \request \request_interface::REQUEST , generate_link_hash ("{$ mode }_ {$ idea_id }" )),
9089 array ('status ' , 0 , false , \phpbb \request \request_interface::REQUEST , 1 ),
9190 array ('v ' , 1 , false , \phpbb \request \request_interface::REQUEST , 1 ),
92- ))) ;
91+ ));
9392
9493 // mock some user permissions during testing
95- $ this ->auth -> expects ( $ this -> any ())
94+ $ this ->auth
9695 ->method ('acl_get ' )
9796 ->with ($ this ->stringContains ('_ ' ), $ this ->anything ())
98- ->will ( $ this -> returnValueMap (array (
97+ ->willReturnMap (array (
9998 array ('m_ ' , 2 , $ authorised ),
10099 array ('f_vote ' , 2 , $ authorised ),
101- ))) ;
100+ ));
102101
103102 // special case, expect trigger_error when a confirm_box return true
104103 if ($ expected === 'trigger_error ' )
@@ -109,7 +108,8 @@ public function test_controller($idea_id, $mode, $callback, $is_ajax, $authorise
109108
110109 if ($ status_code === 403 )
111110 {
112- $ this ->setExpectedException ('\phpbb\exception\http_exception ' , 'NO_AUTH_OPERATION ' );
111+ $ this ->expectException ('\phpbb\exception\http_exception ' );
112+ $ this ->expectExceptionMessage ('NO_AUTH_OPERATION ' );
113113 }
114114
115115 /** @var \phpbb\ideas\controller\idea_controller $controller */
0 commit comments