silverstripe-framework/tests/parsers/SQLFormatterTest.php
Damian Mooyman 8dd644d25d
API Namespace all classes
Namespace all templates
Move difflib and BBCodeParser2 to thirdparty
Remove deprecated API marked for removal in 4.0
2016-09-08 10:23:17 +12:00

46 lines
896 B
PHP

<?php
use SilverStripe\Dev\SapphireTest;
use SilverStripe\View\Parsers\SQLFormatter;
/**
* @package framework
* @subpackage tests
*/
class SQLFormatterTest extends SapphireTest {
public 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'
);
}
}