diff options
Diffstat (limited to 'tests/SqlFormatterTest.php')
-rw-r--r-- | tests/SqlFormatterTest.php | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/tests/SqlFormatterTest.php b/tests/SqlFormatterTest.php index a1679b9..2c587e4 100644 --- a/tests/SqlFormatterTest.php +++ b/tests/SqlFormatterTest.php @@ -25,6 +25,20 @@ class SqlFormatterTest extends PHPUnit_Framework_TestCase { function testHighlight($sql, $html) { $this->assertEquals(trim($html), trim(SqlFormatter::highlight($sql))); } + /** + * @dataProvider highlightCliData + */ + function testCliHighlight($sql, $html) { + SqlFormatter::$cli = true; + $this->assertEquals(trim($html), trim(SqlFormatter::highlight($sql))); + SqlFormatter::$cli = false; + } + /** + * @dataProvider compressData + */ + function testCompress($sql, $html) { + $this->assertEquals(trim($html), trim(SqlFormatter::compress($sql))); + } function testUsePre() { SqlFormatter::$use_pre = false; @@ -82,7 +96,20 @@ class SqlFormatterTest extends PHPUnit_Framework_TestCase { ); } - //$return = array_slice($return, 0, 50); + return $return; + } + + function highlightCliData() { + $clidata = explode("\n\n",file_get_contents(__DIR__."/clihighlight.html")); + $sqlData = $this->sqlData(); + + $return = array(); + foreach($clidata as $i=>$data) { + $return[] = array( + $sqlData[$i], + $data + ); + } return $return; } @@ -99,7 +126,21 @@ class SqlFormatterTest extends PHPUnit_Framework_TestCase { ); } - //$return = array_slice($return, 0, 50); + return $return; + } + + function compressData() { + $compressData = explode("\n\n",file_get_contents(__DIR__."/compress.html")); + $sqlData = $this->sqlData(); + + $return = array(); + foreach($compressData as $i=>$data) { + $return[] = array( + $sqlData[$i], + $data + ); + } + return $return; } @@ -115,7 +156,6 @@ class SqlFormatterTest extends PHPUnit_Framework_TestCase { ); } - //$return = array_slice($return, 0, 50); return $return; } @@ -130,16 +170,25 @@ class SqlFormatterTest extends PHPUnit_Framework_TestCase { $formatHighlight = array(); $highlight = array(); $format = array(); + $compress = array(); + $clihighlight = array(); foreach($this->sqlData as $sql) { $formatHighlight[] = trim(SqlFormatter::format($sql)); $highlight[] = trim(SqlFormatter::highlight($sql)); $format[] = trim(SqlFormatter::format($sql, false)); + $compress[] = trim(SqlFormatter::compress($sql)); + + SqlFormatter::$cli = true; + $clihighlight[] = trim(SqlFormatter::highlight($sql)); + SqlFormatter::$cli = false; } file_put_contents(__DIR__."/format-highlight.html", implode("\n\n",$formatHighlight)); file_put_contents(__DIR__."/highlight.html", implode("\n\n",$highlight)); file_put_contents(__DIR__."/format.html", implode("\n\n",$format)); + file_put_contents(__DIR__."/compress.html", implode("\n\n",$compress)); + file_put_contents(__DIR__."/clihighlight.html", implode("\n\n",$clihighlight)); /**/ return $this->sqlData; |