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