@@ -97,32 +97,57 @@ public function test_enable_failed_returns_expected()
9797 $ this ->assertEquals (['LANG: SOME_ERROR ' ], $ method ->invoke ($ ext ));
9898 }
9999
100+ public function test_enable_failed_returns_parameterized_error ()
101+ {
102+ $ ext = $ this ->getMockBuilder (ext::class)
103+ ->disableOriginalConstructor ()
104+ ->getMock ();
105+
106+ $ this ->setExtErrors ($ ext , [['PHP_VERSION_ERROR ' , '7.1.0 ' , '5.5.0 ' ]]);
107+
108+ $ languageMock = $ this ->createMock (language::class);
109+ $ languageMock ->method ('add_lang ' )->willReturn (null );
110+ $ languageMock ->method ('lang ' )->willReturnCallback (function (...$ args ) {
111+ return implode (': ' , $ args );
112+ });
113+
114+ $ containerMock = $ this ->createMock (ContainerInterface::class);
115+ $ containerMock ->method ('get ' )->with ('language ' )->willReturn ($ languageMock );
116+
117+ $ this ->setProperty ($ ext , 'container ' , $ containerMock );
118+
119+ $ method = (new \ReflectionClass ($ ext ))->getMethod ('enable_failed ' );
120+ $ method ->setAccessible (true );
121+
122+ $ this ->assertEquals (['PHP_VERSION_ERROR:7.1.0:5.5.0 ' ], $ method ->invoke ($ ext ));
123+ }
124+
100125 public function test_phpbb_requirement_min_error ()
101126 {
102127 $ this ->setExtErrors ($ this ->ext , []);
103128 $ this ->invokeProtectedMethod ($ this ->ext , 'phpbb_requirement ' , ['3.2.2 ' ]);
104- $ this ->assertContains ('PHPBB_VERSION_MIN_ERROR ' , $ this ->getExtErrors ($ this ->ext ));
129+ $ this ->assertContains ('PHPBB_VERSION_MIN_ERROR ' , $ this ->getExtErrorKeys ($ this ->ext ));
105130 }
106131
107132 public function test_phpbb_requirement_max_error ()
108133 {
109134 $ this ->setExtErrors ($ this ->ext , []);
110135 $ this ->invokeProtectedMethod ($ this ->ext , 'phpbb_requirement ' , ['4.0.0-dev ' ]);
111- $ this ->assertContains ('PHPBB_VERSION_MAX_ERROR ' , $ this ->getExtErrors ($ this ->ext ));
136+ $ this ->assertContains ('PHPBB_VERSION_MAX_ERROR ' , $ this ->getExtErrorKeys ($ this ->ext ));
112137 }
113138
114139 public function test_php_requirement_error ()
115140 {
116141 $ this ->setExtErrors ($ this ->ext , []);
117142 $ this ->invokeProtectedMethod ($ this ->ext , 'php_requirement ' , [50500 ]);
118- $ this ->assertContains ('PHP_VERSION_ERROR ' , $ this ->getExtErrors ($ this ->ext ));
143+ $ this ->assertContains ('PHP_VERSION_ERROR ' , $ this ->getExtErrorKeys ($ this ->ext ));
119144 }
120145
121146 public function test_ziparchive_exists_error ()
122147 {
123148 $ this ->setExtErrors ($ this ->ext , []);
124149 $ this ->invokeProtectedMethod ($ this ->ext , 'ziparchive_exists ' , ['NotZipArchive ' ]);
125- $ this ->assertContains ('NO_ZIPARCHIVE_ERROR ' , $ this ->getExtErrors ($ this ->ext ));
150+ $ this ->assertContains ('NO_ZIPARCHIVE_ERROR ' , $ this ->getExtErrorKeys ($ this ->ext ));
126151 }
127152
128153 // --- Helpers ---
@@ -138,9 +163,14 @@ protected function getExtErrors($ext): array
138163 {
139164 $ prop = (new \ReflectionClass ($ ext ))->getProperty ('errors ' );
140165 $ prop ->setAccessible (true );
166+ return $ prop ->getValue ($ ext );
167+ }
168+
169+ protected function getExtErrorKeys ($ ext ): array
170+ {
141171 return array_map (static function ($ e ) {
142172 return is_array ($ e ) ? $ e [0 ] : $ e ;
143- }, $ prop -> getValue ($ ext ));
173+ }, $ this -> getExtErrors ($ ext ));
144174 }
145175
146176 protected function setExtErrors ($ ext , array $ errors ): void
0 commit comments