Skip to content

Commit

Permalink
Add basic test for query highlighting in toolbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Schmitz committed Oct 13, 2021
1 parent 00e2681 commit 9c6a355
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/system/Database/BaseQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,29 @@ public function testSetQueryBinds()

$this->assertSame($expected, $query->getQuery());
}

public function queryKeywords()
{
return [
0 => [
'<strong>SELECT</strong> `teams`.*, `players`.`player_id` <strong>AS</strong> `origin_id` <strong>FROM</strong> `teams` <strong>LEFT</strong> <strong>JOIN</strong> `players` <strong>ON</strong> `players`.`team_id` = `teams`.`team_id` <strong>WHERE</strong> `players`.`player_id` <strong>IN</strong> (\'1\') <strong>AND</strong> `teams`.`deleted_at` <strong>IS</strong> <strong>NOT</strong> <strong>NULL</strong>',
'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());
}
}

0 comments on commit 9c6a355

Please sign in to comment.