From 107abea9e10e26b189cc2205a7a06ccac0ebd504 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 21 Mar 2022 09:38:17 +0100 Subject: [PATCH] tests: Introduce `QuoterTest` --- tests/QuoterTest.php | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/QuoterTest.php diff --git a/tests/QuoterTest.php b/tests/QuoterTest.php new file mode 100644 index 0000000..5cfa49d --- /dev/null +++ b/tests/QuoterTest.php @@ -0,0 +1,45 @@ +adapter === null) { + $this->adapter = new TestAdapter(); + } + + return $this->adapter; + } + + /** + * @depends testSimpleNamesAreEscaped + * @depends testRelationPathsAreEscaped + * @depends testArrayValuesAreEscapedAsIs + */ + public function testWildcardsAreNotEscaped() + { + $this->assertEquals('*', $this->db()->quoteIdentifier('*')); + $this->assertEquals('*', $this->db()->quoteIdentifier(['*'])); + $this->assertEquals('"foo".*', $this->db()->quoteIdentifier('foo.*')); + $this->assertEquals('"foo".*', $this->db()->quoteIdentifier(['foo', '*'])); + } + + public function testSimpleNamesAreEscaped() + { + $this->assertEquals('"foo"', $this->db()->quoteIdentifier('foo')); + } + + public function testRelationPathsAreEscaped() + { + $this->assertEquals('"foo"."bar"."rab"."oof"', $this->db()->quoteIdentifier('foo.bar.rab.oof')); + } + + public function testArrayValuesAreEscapedAsIs() + { + $this->assertEquals('"foo.bar"."rab.oof"', $this->db()->quoteIdentifier(['foo.bar', 'rab.oof'])); + } +}