mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-08-26 20:45:47 +02:00
41 lines
814 B
PHP
41 lines
814 B
PHP
|
<?php
|
||
|
/**
|
||
|
* @package sapphire
|
||
|
* @subpackage tests
|
||
|
*/
|
||
|
class SQLFormatterTest extends SapphireTest {
|
||
|
|
||
|
function testNewlineHanding() {
|
||
|
$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;
|
||
|
$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'
|
||
|
);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
?>
|