Skip to content

Commit

Permalink
tests: Introduce QuoterTest
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Mar 21, 2022
1 parent ce0725c commit 107abea
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/QuoterTest.php
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']));
}
}

0 comments on commit 107abea

Please sign in to comment.