summaryrefslogtreecommitdiffstats
path: root/tests/Utils/FormatterTest.php
diff options
context:
space:
mode:
authorDamian Dlugosz <bigfootdd@gmail.com>2017-01-08 20:17:35 +0100
committerDamian Dlugosz <bigfootdd@gmail.com>2017-02-01 23:33:23 +0100
commitfd87828bba25cdfc24b977a19c6571276b3b7d5d (patch)
tree477cd57c2ec29b8155996fd01e36c924742e9a56 /tests/Utils/FormatterTest.php
parente4f682702c43e5251e9868035e4f7d970d97d370 (diff)
downloadsql-parser-fd87828bba25cdfc24b977a19c6571276b3b7d5d.zip
sql-parser-fd87828bba25cdfc24b977a19c6571276b3b7d5d.tar.gz
sql-parser-fd87828bba25cdfc24b977a19c6571276b3b7d5d.tar.bz2
Testing comments
Diffstat (limited to 'tests/Utils/FormatterTest.php')
-rw-r--r--tests/Utils/FormatterTest.php40
1 files changed, 31 insertions, 9 deletions
diff --git a/tests/Utils/FormatterTest.php b/tests/Utils/FormatterTest.php
index af1966f..4cf7879 100644
--- a/tests/Utils/FormatterTest.php
+++ b/tests/Utils/FormatterTest.php
@@ -265,17 +265,39 @@ class FormatTest extends TestCase
'<span class="sql-reserved">SELECT</span>' . '<br/>' .
'&nbsp;&nbsp;&nbsp;&nbsp;*',
),
- 'select with comment' => array(
- 'query' => 'select 1 # Comment',
+ 'select with comments' => array(
+ 'query' =>
+ 'select * /* Comment */' . "\n" .
+ 'from tbl # Comment' . "\n" .
+ 'where 1 -- Comment',
'text' =>
- "SELECT\n" .
- " 1 # Comment" . "\n",
+ "SELECT" . "\n" .
+ " *" . "\n" .
+ " /* Comment */" . "\n" .
+ "FROM" . "\n" .
+ " tbl" . "\n".
+ " # Comment" . "\n" .
+ "WHERE" . "\n" .
+ " 1 -- Comment" . "\n",
'cli' =>
"\x1b[35mSELECT" . "\n" .
- " \x1b[92m1 \x1b[37m# Comment\\x0A" . "\x1b[0m",
+ " \x1b[39m*" . "\n" .
+ " \x1b[37m/* Comment */" . "\n" .
+ "\x1b[35mFROM" . "\n" .
+ " \x1b[39mtbl" . "\n" .
+ " \x1b[37m# Comment\\x0A" .
+ "\x1b[35mWHERE" . "\n" .
+ " \x1b[92m1 \x1b[37m-- Comment\\x0A" . "\x1b[0m",
'html' =>
'<span class="sql-reserved">SELECT</span>' . '<br/>' .
- '&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span> <span class="sql-comment"># Comment' . "\n" .
+ '&nbsp;&nbsp;&nbsp;&nbsp;*' . '<br/>' .
+ ' <span class="sql-comment">/* Comment */</span>' . "\n" .
+ '<span class="sql-reserved">FROM</span>' . '<br/>' .
+ '&nbsp;&nbsp;&nbsp;&nbsp;tbl' . '<br/>' .
+ ' <span class="sql-comment"># Comment' . "\n" .
+ '</span>' .
+ '<span class="sql-reserved">WHERE</span>' . '<br/>' .
+ '&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span> <span class="sql-comment">-- Comment' . "\n" .
'</span>',
),
);
@@ -295,7 +317,7 @@ class FormatTest extends TestCase
public function formatQueries()
{
return array(
- array(
+ array( # DONE
'SELECT 1',
'<span class="sql-reserved">SELECT</span>' . '<br/>' .
'&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span>',
@@ -313,13 +335,13 @@ class FormatTest extends TestCase
' 1 -- Comment',
array('type' => 'text'),
),
- array(
+ array( # DONE
'SELECT 1 # Comment',
'<span class="sql-reserved">SELECT</span>' . '<br/>' .
'&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span> <span class="sql-comment"># Comment</span>',
array('type' => 'html'),
),
- array(
+ array( # DONE
'SELECT 1 -- comment',
'<span class="sql-reserved">SELECT</span>' . '<br/>' .
'&nbsp;&nbsp;&nbsp;&nbsp;<span class="sql-number">1</span> <span class="sql-comment">-- comment</span>',