From 9c6a355acfd16528b273dd06dce1abdf129fdf9d Mon Sep 17 00:00:00 2001 From: Alex Schmitz Date: Wed, 13 Oct 2021 08:07:58 +0200 Subject: [PATCH] Add basic test for query highlighting in toolbar. --- tests/system/Database/BaseQueryTest.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/system/Database/BaseQueryTest.php b/tests/system/Database/BaseQueryTest.php index deec43c4f5bb..e73499e2a93e 100644 --- a/tests/system/Database/BaseQueryTest.php +++ b/tests/system/Database/BaseQueryTest.php @@ -363,4 +363,29 @@ public function testSetQueryBinds() $this->assertSame($expected, $query->getQuery()); } + + public function queryKeywords() + { + return [ + 0 => [ + 'SELECT `teams`.*, `players`.`player_id` AS `origin_id` FROM `teams` LEFT JOIN `players` ON `players`.`team_id` = `teams`.`team_id` WHERE `players`.`player_id` IN (\'1\') AND `teams`.`deleted_at` IS NOT NULL', + 'SELECT `teams`.*, `players`.`player_id` AS `origin_id` FROM `teams` LEFT JOIN `players` ON `players`.`team_id` = `teams`.`team_id` WHERE `players`.`player_id` IN (\'1\') AND `teams`.`deleted_at` IS NOT NULL', + ], + ]; + } + + /** + * @dataProvider queryKeywords + * + * @param mixed $expected + * @param mixed $sql + */ + public function testHighlightQueryKeywords($expected, $sql) + { + $query = new Query($this->db); + $query->setQuery($sql); + $query->getQuery(); + + $this->assertSame($expected, $query->debugToolbarDisplay()); + } }