summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJeremy Dorn <jeremy@jeremydorn.com>2013-03-07 18:26:59 -0800
committerJeremy Dorn <jeremy@jeremydorn.com>2013-03-07 18:26:59 -0800
commit2724ddb7fb79851a557d868a688fc269960bff87 (patch)
tree40e791d5e1d485392ec095f51fdd0ce4acc82814 /tests
parent17fdbb8bd358d226dc1a9691c2245f041d72e3d3 (diff)
downloadsql-formatter-2724ddb7fb79851a557d868a688fc269960bff87.zip
sql-formatter-2724ddb7fb79851a557d868a688fc269960bff87.tar.gz
sql-formatter-2724ddb7fb79851a557d868a688fc269960bff87.tar.bz2
Fixed formatting bug with multiple boundary characters (e.g. ">=", "<>", etc.). Fixes #29
Improved code coverage in unit tests. Now everything is covered except the infinite loop catching code which I don't know how to test.
Diffstat (limited to 'tests')
-rw-r--r--tests/SqlFormatterTest.php12
-rw-r--r--tests/format-highlight.html6
-rw-r--r--tests/format.html6
-rw-r--r--tests/highlight.html6
-rw-r--r--tests/sql.sql4
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