silverstripe-framework/tests/php/View/Parsers/SQLFormatterTest.php

43 lines
888 B
PHP
Raw Normal View History

<?php
2016-10-14 03:30:05 +02:00
namespace SilverStripe\View\Tests\Parsers;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\View\Parsers\SQLFormatter;
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'
);
}
}