@@ -57,9 +57,9 @@ protected function setUp(): void
5757 $ phpbb_dispatcher = new phpbb_mock_event_dispatcher ();
5858 }
5959
60- public function test_module_info ()
60+ public function test_module_info (): void
6161 {
62- self :: assertEquals ( [
62+ $ expected = [
6363 '\\phpbb \\pwakit \\acp \\pwa_acp_module ' => [
6464 'filename ' => '\\phpbb \\pwakit \\acp \\pwa_acp_module ' ,
6565 'title ' => 'ACP_PWA_KIT_TITLE ' ,
@@ -71,10 +71,15 @@ public function test_module_info()
7171 ],
7272 ],
7373 ],
74- ], $ this ->module_manager ->get_module_infos ('acp ' , 'pwa_acp_module ' ));
74+ ];
75+
76+ $ this ->assertSame (
77+ $ expected ,
78+ $ this ->module_manager ->get_module_infos ('acp ' , 'pwa_acp_module ' )
79+ );
7580 }
7681
77- public function module_auth_test_data (): array
82+ public static function module_auth_test_data (): array
7883 {
7984 return [
8085 'invalid auth ' => ['ext_foo/bar ' , false ],
@@ -85,12 +90,12 @@ public function module_auth_test_data(): array
8590 /**
8691 * @dataProvider module_auth_test_data
8792 */
88- public function test_module_auth ($ module_auth , $ expected )
93+ public function test_module_auth (string $ module_auth , bool $ expected ): void
8994 {
90- self :: assertEquals ($ expected , p_master::module_auth ($ module_auth , 0 ));
95+ $ this -> assertEquals ($ expected , p_master::module_auth ($ module_auth , 0 ));
9196 }
9297
93- public function main_module_test_data (): array
98+ public static function main_module_test_data (): array
9499 {
95100 return [
96101 'valid mode ' => ['settings ' ],
@@ -100,7 +105,7 @@ public function main_module_test_data(): array
100105 /**
101106 * @dataProvider main_module_test_data
102107 */
103- public function test_main_module ($ mode )
108+ public function test_main_module (string $ mode ): void
104109 {
105110 global $ phpbb_container , $ request , $ template ;
106111
@@ -123,18 +128,56 @@ public function test_main_module($mode)
123128 ->getMock ();
124129
125130 $ phpbb_container
126- ->expects (self :: once ())
131+ ->expects ($ this -> once ())
127132 ->method ('get ' )
128133 ->with ('phpbb.pwakit.admin.controller ' )
129134 ->willReturn ($ admin_controller );
130135
131136 $ admin_controller
132- ->expects (self :: once ())
137+ ->expects ($ this -> once ())
133138 ->method ('main ' );
134139
135140 $ p_master = new p_master ();
136141 $ p_master ->module_ary [0 ]['is_duplicate ' ] = 0 ;
137142 $ p_master ->module_ary [0 ]['url_extra ' ] = '' ;
138143 $ p_master ->load ('acp ' , pwa_acp_module::class, $ mode );
139144 }
145+
146+ public function test_main_module_with_missing_controller (): void
147+ {
148+ global $ phpbb_container , $ template , $ request ;
149+
150+ $ this ->expectException (\RuntimeException::class);
151+ $ this ->expectExceptionMessage ('Service not found: phpbb.pwakit.admin.controller ' );
152+
153+ if (!defined ('IN_ADMIN ' )) {
154+ define ('IN_ADMIN ' , true );
155+ }
156+
157+ // Set up template mock
158+ $ template = $ this ->getMockBuilder (template::class)
159+ ->disableOriginalConstructor ()
160+ ->getMock ();
161+
162+ // Set up request mock
163+ $ request = $ this ->getMockBuilder (request::class)
164+ ->disableOriginalConstructor ()
165+ ->getMock ();
166+
167+ // Set up container mock
168+ $ phpbb_container = $ this ->getMockBuilder (ContainerInterface::class)
169+ ->disableOriginalConstructor ()
170+ ->getMock ();
171+
172+ $ phpbb_container
173+ ->expects ($ this ->once ())
174+ ->method ('get ' )
175+ ->with ('phpbb.pwakit.admin.controller ' )
176+ ->willThrowException (new \RuntimeException ('Service not found: phpbb.pwakit.admin.controller ' ));
177+
178+ $ p_master = new p_master ();
179+ $ p_master ->module_ary [0 ]['is_duplicate ' ] = 0 ;
180+ $ p_master ->module_ary [0 ]['url_extra ' ] = '' ;
181+ $ p_master ->load ('acp ' , pwa_acp_module::class, 'settings ' );
182+ }
140183}
0 commit comments