diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/SqlFormatterTest.php | 12 | ||||
-rw-r--r-- | tests/format-highlight.html | 6 | ||||
-rw-r--r-- | tests/format.html | 6 | ||||
-rw-r--r-- | tests/highlight.html | 6 | ||||
-rw-r--r-- | tests/sql.sql | 4 |
5 files changed, 23 insertions, 11 deletions
diff --git a/tests/SqlFormatterTest.php b/tests/SqlFormatterTest.php index 5cf65ad..2bd8f7f 100644 --- a/tests/SqlFormatterTest.php +++ b/tests/SqlFormatterTest.php @@ -23,6 +23,18 @@ class SqlFormatterTest extends PHPUnit_Framework_TestCase { $this->assertEquals(trim($html), trim(SqlFormatter::highlight($sql))); } + function testUsePre() { + SqlFormatter::$use_pre = false; + $actual = SqlFormatter::highlight("test"); + $expected = '<span style="color: #333;">test</span>'; + $this->assertEquals($actual,$expected); + + SqlFormatter::$use_pre = true; + $actual = SqlFormatter::highlight("test"); + $expected = '<pre style="color: black; background-color: white;"><span style="color: #333;">test</span></pre>'; + $this->assertEquals($actual,$expected); + } + function testSplitQuery() { $expected = array( "SELECT 'test' FROM MyTable;", diff --git a/tests/format-highlight.html b/tests/format-highlight.html index f64da33..0be035d 100644 --- a/tests/format-highlight.html +++ b/tests/format-highlight.html @@ -799,6 +799,8 @@ <span style="font-weight:bold;">WHERE</span> <span style="color: green;">1</span> <span >=</span> <span style="color: green;">2</span><span >;</span></pre> +<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: #aaa;">-- This is a test</span></pre> + <pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: #333;">Test</span> <span style="font-weight:bold;">FROM</span> @@ -808,6 +810,4 @@ <span style="background-color: red;">)</span><span style="font-weight:bold;">AND</span> ( ( (<span style="color: #333;">SomeOtherColumn</span> <span >=</span> <span style="color: green;">2</span>)<span >;</span> -<span style="background-color: red;">WARNING: unclosed parentheses or section</span></pre> - -<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: #aaa;">-- This is a test</span></pre>
\ No newline at end of file +<span style="background-color: red;">WARNING: unclosed parentheses or section</span></pre>
\ No newline at end of file diff --git a/tests/format.html b/tests/format.html index 32514ce..e806f6d 100644 --- a/tests/format.html +++ b/tests/format.html @@ -799,6 +799,8 @@ FROM -- This is another comment WHERE 1 = 2; +SELECT -- This is a test + SELECT Test FROM @@ -807,6 +809,4 @@ WHERE (MyColumn = 1) ) AND ( ( - (SomeOtherColumn = 2); - -SELECT -- This is a test
\ No newline at end of file + (SomeOtherColumn = 2);
\ No newline at end of file diff --git a/tests/highlight.html b/tests/highlight.html index b18d77b..f5b3ea9 100644 --- a/tests/highlight.html +++ b/tests/highlight.html @@ -238,8 +238,8 @@ <span style="color: #aaa;">/* This is a block comment */</span> <span style="font-weight:bold;">WHERE</span> <span style="color: green;">1</span> <span >=</span> <span style="color: green;">2</span><span >;</span></pre> +<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: #aaa;">-- This is a test</span></pre> + <pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: #333;">Test</span> <span style="font-weight:bold;">FROM</span> <span style="color: #333;">Test</span> <span style="font-weight:bold;">WHERE</span> ( - <span style="color: #333;">MyColumn</span> <span >=</span> <span style="color: green;">1</span> )) <span style="font-weight:bold;">AND</span> ((( <span style="color: #333;">SomeOtherColumn</span> <span >=</span> <span style="color: green;">2</span>)<span >;</span></pre> - -<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: #aaa;">-- This is a test</span></pre>
\ No newline at end of file + <span style="color: #333;">MyColumn</span> <span >=</span> <span style="color: green;">1</span> )) <span style="font-weight:bold;">AND</span> ((( <span style="color: #333;">SomeOtherColumn</span> <span >=</span> <span style="color: green;">2</span>)<span >;</span></pre>
\ No newline at end of file diff --git a/tests/sql.sql b/tests/sql.sql index ed92aa6..f1b358f 100644 --- a/tests/sql.sql +++ b/tests/sql.sql @@ -238,8 +238,8 @@ MyTable # One final comment /* This is a block comment */ WHERE 1 = 2; +SELECT -- This is a test + SELECT Test FROM Test WHERE ( MyColumn = 1 )) AND ((( SomeOtherColumn = 2); - -SELECT -- This is a test |