@@ -731,6 +731,11 @@ public function providerExtractValueFromFormattedSize(): array
731731 ];
732732 }
733733
734+ public function testFormatByteDownWithNullValue (): void
735+ {
736+ $ this ->assertNull (Util::formatByteDown (null ));
737+ }
738+
734739 /**
735740 * format byte test, globals are defined
736741 *
@@ -2234,4 +2239,105 @@ public function testGetScriptNameForOption(string $target, string $location, str
22342239 Util::getScriptNameForOption ($ target , $ location )
22352240 );
22362241 }
2242+
2243+ public function testShowIcons (): void
2244+ {
2245+ $ GLOBALS ['cfg ' ]['ActionLinksMode ' ] = 'icons ' ;
2246+ $ this ->assertTrue (Util::showIcons ('ActionLinksMode ' ));
2247+ $ GLOBALS ['cfg ' ]['ActionLinksMode ' ] = 'both ' ;
2248+ $ this ->assertTrue (Util::showIcons ('ActionLinksMode ' ));
2249+ $ GLOBALS ['cfg ' ]['ActionLinksMode ' ] = 'text ' ;
2250+ $ this ->assertFalse (Util::showIcons ('ActionLinksMode ' ));
2251+ }
2252+
2253+ public function testShowText (): void
2254+ {
2255+ $ GLOBALS ['cfg ' ]['ActionLinksMode ' ] = 'text ' ;
2256+ $ this ->assertTrue (Util::showText ('ActionLinksMode ' ));
2257+ $ GLOBALS ['cfg ' ]['ActionLinksMode ' ] = 'both ' ;
2258+ $ this ->assertTrue (Util::showText ('ActionLinksMode ' ));
2259+ $ GLOBALS ['cfg ' ]['ActionLinksMode ' ] = 'icons ' ;
2260+ $ this ->assertFalse (Util::showText ('ActionLinksMode ' ));
2261+ }
2262+
2263+ /**
2264+ * @dataProvider providerForTestGetMySQLDocuURL
2265+ */
2266+ public function testGetMySQLDocuURL (string $ link , string $ anchor , int $ version , string $ expected ): void
2267+ {
2268+ $ GLOBALS ['dbi ' ] = $ this ->createDatabaseInterface ();
2269+ $ GLOBALS ['dbi ' ]->setVersion ($ version );
2270+ $ this ->assertSame ($ expected , Util::getMySQLDocuURL ($ link , $ anchor ));
2271+ }
2272+
2273+ /**
2274+ * @return array<int, array<int, int|string>>
2275+ * @psalm-return array<int, array{string, string, int, string}>
2276+ */
2277+ public function providerForTestGetMySQLDocuURL (): array
2278+ {
2279+ return [
2280+ [
2281+ 'ALTER_TABLE ' ,
2282+ 'alter-table-index ' ,
2283+ 80000 ,
2284+ 'index.php?route=/url&url= '
2285+ . 'https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F8.0%2Fen%2Falter-table.html%23alter-table-index ' ,
2286+ ],
2287+ [
2288+ 'ALTER_TABLE ' ,
2289+ 'alter-table-index ' ,
2290+ 50700 ,
2291+ 'index.php?route=/url&url= '
2292+ . 'https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2Falter-table.html%23alter-table-index ' ,
2293+ ],
2294+ [
2295+ '' ,
2296+ 'alter-table-index ' ,
2297+ 50600 ,
2298+ 'index.php?route=/url&url= '
2299+ . 'https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.6%2Fen%2Findex.html%23alter-table-index ' ,
2300+ ],
2301+ [
2302+ 'ALTER_TABLE ' ,
2303+ '' ,
2304+ 50500 ,
2305+ 'index.php?route=/url&url= '
2306+ . 'https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.5%2Fen%2Falter-table.html ' ,
2307+ ],
2308+ [
2309+ '' ,
2310+ '' ,
2311+ 50700 ,
2312+ 'index.php?route=/url&url= '
2313+ . 'https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2Findex.html ' ,
2314+ ],
2315+ ];
2316+ }
2317+
2318+ public function testGetDocuURL (): void
2319+ {
2320+ $ this ->assertSame (
2321+ 'index.php?route=/url&url=https%3A%2F%2Fmariadb.com%2Fkb%2Fen%2Fdocumentation%2F ' ,
2322+ Util::getDocuURL (true )
2323+ );
2324+ $ this ->assertSame (
2325+ 'index.php?route=/url&url=https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.5%2Fen%2Findex.html ' ,
2326+ Util::getDocuURL (false )
2327+ );
2328+ $ this ->assertSame (
2329+ 'index.php?route=/url&url=https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.5%2Fen%2Findex.html ' ,
2330+ Util::getDocuURL ()
2331+ );
2332+ }
2333+
2334+ public function testSplitURLQuery (): void
2335+ {
2336+ $ actual = Util::splitURLQuery ('' );
2337+ $ this ->assertSame ([], $ actual );
2338+ $ actual = Util::splitURLQuery ('index.php ' );
2339+ $ this ->assertSame ([], $ actual );
2340+ $ actual = Util::splitURLQuery ('index.php?route=/table/structure&db=sakila&table=address ' );
2341+ $ this ->assertSame (['route=/table/structure ' , 'db=sakila ' , 'table=address ' ], $ actual );
2342+ }
22372343}
0 commit comments