silverstripe-framework/tests/parsers/SQLFormatterTest.php

42 lines
815 B
PHP
Raw Normal View History

<?php
/**
* @package framework
* @subpackage tests
*/
class SQLFormatterTest extends SapphireTest {
2014-08-15 08:53:05 +02:00
public function testNewlineHanding() {
$formatter = new SQLFormatter();
2014-08-15 08:53:05 +02:00
$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'
);
2014-08-15 08:53:05 +02:00
$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'
);
}
2014-08-15 08:53:05 +02:00
}