2008-09-16 20:12:07 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2008-09-16 20:12:07 +02:00
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class SQLFormatterTest extends SapphireTest {
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testNewlineHanding() {
|
2008-09-16 20:12:07 +02:00
|
|
|
$formatter = new SQLFormatter();
|
|
|
|
|
|
|
|
$sqlBefore = <<<SQL
|
|
|
|
SELECT Test.Foo, Test.Bar FROM Test WHERE 'From' = "Where"
|
|
|
|
SQL;
|
|
|
|
$sqlAfter = <<<SQL
|
|
|
|
SELECT Test.Foo, Test.Bar
|
|
|
|
FROM Test
|
|
|
|
WHERE 'From' = "Where"
|
|
|
|
SQL;
|
2009-11-21 02:43:54 +01:00
|
|
|
|
2008-09-16 20:12:07 +02:00
|
|
|
$this->assertEquals($formatter->formatPlain($sqlBefore), $sqlAfter,
|
|
|
|
'correct replacement of newlines and don\'t replace non-uppercase tokens'
|
|
|
|
);
|
|
|
|
|
|
|
|
$sqlBefore = <<<SQL
|
|
|
|
SELECT Test.Foo, Test.Bar
|
|
|
|
FROM Test
|
|
|
|
WHERE
|
|
|
|
'From' = "Where"
|
|
|
|
SQL;
|
|
|
|
$sqlAfter = <<<SQL
|
|
|
|
SELECT Test.Foo, Test.Bar
|
|
|
|
FROM Test
|
|
|
|
WHERE
|
|
|
|
'From' = "Where"
|
|
|
|
SQL;
|
|
|
|
$this->assertEquals($formatter->formatPlain($sqlBefore), $sqlAfter,
|
|
|
|
'Leave existing newlines and indentation in place'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|