@@ -62,6 +62,46 @@ public function testPMAGetDisplayField(): void
6262 '' ,
6363 $ relation ->getDisplayField ($ db , $ table ),
6464 );
65+
66+ $ relationParameters = RelationParameters::fromArray ([
67+ 'displaywork ' => true ,
68+ 'db ' => 'pmadb ' ,
69+ 'table_info ' => 'table_info ' ,
70+ 'relation ' => 'relation ' ,
71+ ]);
72+ (new ReflectionProperty (Relation::class, 'cache ' ))->setValue (null , $ relationParameters );
73+
74+ $ dummyDbi ->addResult (
75+ 'SELECT `display_field` FROM `pmadb`.`table_info` '
76+ . ' WHERE `db_name` = \'information_schema \' AND `table_name` = \'PMA \'' ,
77+ [['TABLE_COMMENT ' ]],
78+ ['display_field ' ],
79+ );
80+ $ db = 'information_schema ' ;
81+ $ table = 'PMA ' ;
82+ self ::assertSame (
83+ 'TABLE_COMMENT ' ,
84+ $ relation ->getDisplayField ($ db , $ table ),
85+ );
86+
87+ $ dummyDbi ->addResult (
88+ 'SELECT `display_field` FROM `pmadb`.`table_info` '
89+ . ' WHERE `db_name` = \'information_schema \' AND `table_name` = \'NON_EXISTING_TABLE \'' ,
90+ [],
91+ );
92+ $ dummyDbi ->addResult (
93+ 'SELECT *, `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`, '
94+ . ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`, `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, '
95+ . ' `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment` FROM `information_schema`.`COLUMNS` '
96+ . ' WHERE `TABLE_SCHEMA` = \'information_schema \' AND `TABLE_NAME` = \'NON_EXISTING_TABLE \'' ,
97+ [],
98+ );
99+ $ db = 'information_schema ' ;
100+ $ table = 'NON_EXISTING_TABLE ' ;
101+ self ::assertSame (
102+ '' ,
103+ $ relation ->getDisplayField ($ db , $ table ),
104+ );
65105 }
66106
67107 /**
0 commit comments