Commit 2b01d9ab authored by Steve Müller's avatar Steve Müller

#657 - make unit test cases for quoting string literals easier extendable

parent bb12840b
...@@ -871,24 +871,64 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -871,24 +871,64 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->assertSame($this->getStringLiteralQuoteCharacter(), $this->_platform->getStringLiteralQuoteCharacter()); $this->assertSame($this->getStringLiteralQuoteCharacter(), $this->_platform->getStringLiteralQuoteCharacter());
} }
public function testGetCommentOnColumnSQL() protected function getQuotedCommentOnColumnSQLWithoutQuoteCharacter()
{
return "COMMENT ON COLUMN mytable.id IS 'This is a comment'";
}
public function testGetCommentOnColumnSQLWithoutQuoteCharacter()
{ {
$this->assertEquals( $this->assertEquals(
"COMMENT ON COLUMN mytable.id IS 'This is a comment'", $this->getQuotedCommentOnColumnSQLWithoutQuoteCharacter(),
$this->_platform->getCommentOnColumnSQL('mytable', 'id', 'This is a comment') $this->_platform->getCommentOnColumnSQL('mytable', 'id', 'This is a comment')
); );
}
protected function getQuotedCommentOnColumnSQLWithQuoteCharacter()
{
return "COMMENT ON COLUMN mytable.id IS 'It''s a quote !'";
}
public function testGetCommentOnColumnSQLWithQuoteCharacter()
{
$c = $this->getStringLiteralQuoteCharacter();
$this->assertEquals( $this->assertEquals(
"COMMENT ON COLUMN mytable.id IS 'It''s a quote !'", $this->getQuotedCommentOnColumnSQLWithQuoteCharacter(),
$this->_platform->getCommentOnColumnSQL('mytable', 'id', "It's a quote !") $this->_platform->getCommentOnColumnSQL('mytable', 'id', "It" . $c . "s a quote !")
); );
} }
protected function getQuotedStringLiteralWithoutQuoteCharacter()
{
return "'No quote'";
}
protected function getQuotedStringLiteralWithQuoteCharacter()
{
return "'It''s a quote'";
}
protected function getQuotedStringLiteralQuoteCharacter()
{
return "''''";
}
public function testQuoteStringLiteral() public function testQuoteStringLiteral()
{ {
$c = $this->_platform->getStringLiteralQuoteCharacter(); $c = $this->getStringLiteralQuoteCharacter();
$this->assertEquals($c . 'No quote' . $c, $this->_platform->quoteStringLiteral('No quote'));
$this->assertEquals($c . 'It' . $c . $c . 's a quote' . $c, $this->_platform->quoteStringLiteral('It' . $c . 's a quote')); $this->assertEquals(
$this->assertEquals($c . $c . $c . $c, $this->_platform->quoteStringLiteral($c)); $this->getQuotedStringLiteralWithoutQuoteCharacter(),
$this->_platform->quoteStringLiteral('No quote')
);
$this->assertEquals(
$this->getQuotedStringLiteralWithQuoteCharacter(),
$this->_platform->quoteStringLiteral('It' . $c . 's a quote')
);
$this->assertEquals(
$this->getQuotedStringLiteralQuoteCharacter(),
$this->_platform->quoteStringLiteral($c)
);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment