-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from Icinga/support-dots-in-identifiers
Quoter: Accept arrays of strings and quote parts as-is
- Loading branch information
Showing
3 changed files
with
65 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace ipl\Tests\Sql; | ||
|
||
class QuoterTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
protected $adapter; | ||
|
||
protected function db() | ||
{ | ||
if ($this->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'])); | ||
} | ||
} |