diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-06-13 15:19:31 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-06-13 15:19:31 +0300 |
commit | 7ad9549468007c37c0eddda0cd969c648aa779a1 (patch) | |
tree | 3e434aab902b0b4df7f023f49e7dac1840b88350 /tests | |
parent | 175c41608e2cc586c5cf603ed2cb0d307ad632ad (diff) | |
download | sql-parser-7ad9549468007c37c0eddda0cd969c648aa779a1.zip sql-parser-7ad9549468007c37c0eddda0cd969c648aa779a1.tar.gz sql-parser-7ad9549468007c37c0eddda0cd969c648aa779a1.tar.bz2 |
Follow the PSR2 standard.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bootstrap.php | 4 | ||||
-rw-r--r-- | tests/lexer/IsMethodsTest.php | 6 | ||||
-rw-r--r-- | tests/lexer/LexerTest.php | 104 | ||||
-rw-r--r-- | tests/lexer/TokenTest.php | 6 | ||||
-rw-r--r-- | tests/lexer/TokensList.php | 4 | ||||
-rw-r--r-- | tests/parser/ArrayFragmentTest.php | 24 | ||||
-rw-r--r-- | tests/parser/CallStatementTest.php | 18 | ||||
-rw-r--r-- | tests/parser/CreateStatementTest.php | 36 | ||||
-rw-r--r-- | tests/parser/DeleteStatementTest.php | 18 | ||||
-rw-r--r-- | tests/parser/InsertStatementTest.php | 18 | ||||
-rw-r--r-- | tests/parser/ParserTest.php | 4 | ||||
-rw-r--r-- | tests/parser/RenameStatementTest.php | 18 | ||||
-rw-r--r-- | tests/parser/ReplaceStatementTest.php | 18 | ||||
-rw-r--r-- | tests/parser/SelectStatementTest.php | 26 | ||||
-rw-r--r-- | tests/parser/UpdateStatementTest.php | 18 | ||||
-rw-r--r-- | tests/utils/MiscTest.php | 5 | ||||
-rw-r--r-- | tests/utils/RoutineTest.php | 8 |
17 files changed, 198 insertions, 137 deletions
diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e7aa672..549cc96 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,5 +1,7 @@ <?php +namespace SqlParser\Tests; + require('vendor/autoload.php'); use SqlParser\Lexer; @@ -18,7 +20,7 @@ use SqlParser\Token; * which holds the Parser instance, without errors and the `errors` key which * holds the array that was previously extracted. */ -abstract class TestCase extends PHPUnit_Framework_TestCase +abstract class TestCase extends \PHPUnit_Framework_TestCase { /** diff --git a/tests/lexer/IsMethodsTest.php b/tests/lexer/IsMethodsTest.php index 6121a4d..d1d9546 100644 --- a/tests/lexer/IsMethodsTest.php +++ b/tests/lexer/IsMethodsTest.php @@ -1,9 +1,13 @@ <?php +namespace SqlParser\Tests\Lexer; + use SqlParser\Context; use SqlParser\Token; -class IsMethodsTest extends PHPUnit_Framework_TestCase +use SqlParser\Tests\TestCase; + +class IsMethodsTest extends TestCase { public function testIsKeyword() diff --git a/tests/lexer/LexerTest.php b/tests/lexer/LexerTest.php index c8f941d..9620ee7 100644 --- a/tests/lexer/LexerTest.php +++ b/tests/lexer/LexerTest.php @@ -1,8 +1,12 @@ <?php +namespace SqlParser\Tests\Lexer; + use SqlParser\Exceptions\LexerException; use SqlParser\Lexer; +use SqlParser\Tests\TestCase; + class LexerTest extends TestCase { @@ -32,78 +36,32 @@ class LexerTest extends TestCase $lexer->error('strict error', 'foo', 1, 4); } - public function testLex() - { - $this->runLexerTest('lex'); - } - - public function testLexKeyword() - { - $this->runLexerTest('lexKeyword'); - } - - public function testLexOperator() - { - $this->runLexerTest('lexOperator'); - } - - public function testLexWhitespace() - { - $this->runLexerTest('lexWhitespace'); - } - - public function testLexComment() - { - $this->runLexerTest('lexComment'); - } - - public function testLexBool() - { - $this->runLexerTest('lexBool'); - } - - public function testLexNumber() - { - $this->runLexerTest('lexNumber'); - } - - public function testLexString() - { - $this->runLexerTest('lexString'); - } - - public function testLexStringErr1() - { - $this->runLexerTest('lexStringErr1'); - } - - public function testLexSymbol() - { - $this->runLexerTest('lexSymbol'); - } - - public function testLexSymbolUser() - { - $this->runLexerTest('lexSymbolUser'); - } - - public function testLexSymbolErr1() - { - $this->runLexerTest('lexSymbolErr1'); - } - - public function testLexSymbolErr2() - { - $this->runLexerTest('lexSymbolErr2'); - } - - public function testLexSymbolErr3() - { - $this->runLexerTest('lexSymbolErr3'); - } - - public function testLexDelimiter() - { - $this->runLexerTest('lexDelimiter'); + /** + * @dataProvider testLexProvider + */ + public function testLex($test) + { + $this->runLexerTest($test); + } + + public function testLexProvider() + { + return array( + array('lex'), + array('lexKeyword'), + array('lexOperator'), + array('lexWhitespace'), + array('lexComment'), + array('lexBool'), + array('lexNumber'), + array('lexString'), + array('lexStringErr1'), + array('lexSymbol'), + array('lexSymbolUser'), + array('lexSymbolErr1'), + array('lexSymbolErr2'), + array('lexSymbolErr3'), + array('lexDelimiter'), + ); } } diff --git a/tests/lexer/TokenTest.php b/tests/lexer/TokenTest.php index 02e9ff1..640d4ed 100644 --- a/tests/lexer/TokenTest.php +++ b/tests/lexer/TokenTest.php @@ -1,8 +1,12 @@ <?php +namespace SqlParser\Tests\Lexer; + use SqlParser\Token; -class TokenTest extends PHPUnit_Framework_TestCase +use SqlParser\Tests\TestCase; + +class TokenTest extends TestCase { public function testExtractKeyword() diff --git a/tests/lexer/TokensList.php b/tests/lexer/TokensList.php index 0415a8e..8887241 100644 --- a/tests/lexer/TokensList.php +++ b/tests/lexer/TokensList.php @@ -1,8 +1,12 @@ <?php +namespace SqlParser\Tests\Lexer; + use SqlParser\Token; use SqlParser\TokensList; +use SqlParser\Tests\TestCase; + class TokensListCase extends TestCase { diff --git a/tests/parser/ArrayFragmentTest.php b/tests/parser/ArrayFragmentTest.php index ad40385..a31bf2a 100644 --- a/tests/parser/ArrayFragmentTest.php +++ b/tests/parser/ArrayFragmentTest.php @@ -1,20 +1,26 @@ <?php +namespace SqlParser\Tests\Parser; + +use SqlParser\Tests\TestCase; + class ArrayFragmentTest extends TestCase { - public function testArrayErr1() - { - $this->runParserTest('parseArrayErr1'); - } - - public function testArrayErr2() + /** + * @dataProvider testArrayProvider + */ + public function testArray($test) { - $this->runParserTest('parseArrayErr2'); + $this->runParserTest($test); } - public function testArrayErr3() + public function testArrayProvider() { - $this->runParserTest('parseArrayErr3'); + return array( + array('parseArrayErr1'), + array('parseArrayErr2'), + array('parseArrayErr3'), + ); } } diff --git a/tests/parser/CallStatementTest.php b/tests/parser/CallStatementTest.php index c558ce1..f017b14 100644 --- a/tests/parser/CallStatementTest.php +++ b/tests/parser/CallStatementTest.php @@ -1,15 +1,25 @@ <?php +namespace SqlParser\Tests\Parser; + +use SqlParser\Tests\TestCase; + class CallStatementTest extends TestCase { - public function testCall() + /** + * @dataProvider testCallProvider + */ + public function testCall($test) { - $this->runParserTest('parseCall'); + $this->runParserTest($test); } - public function testCall2() + public function testCallProvider() { - $this->runParserTest('parseCall2'); + return array( + array('parseCall'), + array('parseCall2'), + ); } } diff --git a/tests/parser/CreateStatementTest.php b/tests/parser/CreateStatementTest.php index b23e4ab..edd71fe 100644 --- a/tests/parser/CreateStatementTest.php +++ b/tests/parser/CreateStatementTest.php @@ -1,30 +1,28 @@ <?php -class CreateStatementTest extends TestCase -{ +namespace SqlParser\Tests\Parser; - public function testCreateTable() - { - $this->runParserTest('parseCreateTable'); - } +use SqlParser\Tests\TestCase; - public function testCreateProcedure() - { - $this->runParserTest('parseCreateProcedure'); - } - - public function testCreateProcedure2() - { - $this->runParserTest('parseCreateProcedure2'); - } +class CreateStatementTest extends TestCase +{ - public function testCreateFunction() + /** + * @dataProvider testCreateProvider + */ + public function testCreate($test) { - $this->runParserTest('parseCreateFunction'); + $this->runParserTest($test); } - public function testCreateFunctionErr1() + public function testCreateProvider() { - $this->runParserTest('parseCreateFunctionErr1'); + return array( + array('parseCreateTable'), + array('parseCreateProcedure'), + array('parseCreateProcedure2'), + array('parseCreateFunction'), + array('parseCreateFunctionErr1'), + ); } } diff --git a/tests/parser/DeleteStatementTest.php b/tests/parser/DeleteStatementTest.php index dab28c7..d6180e7 100644 --- a/tests/parser/DeleteStatementTest.php +++ b/tests/parser/DeleteStatementTest.php @@ -1,10 +1,24 @@ <?php +namespace SqlParser\Tests\Parser; + +use SqlParser\Tests\TestCase; + class DeleteStatementTest extends TestCase { - public function testDelete() + /** + * @dataProvider testDeleteProvider + */ + public function testDelete($test) + { + $this->runParserTest($test); + } + + public function testDeleteProvider() { - $this->runParserTest('parseDelete'); + return array( + array('parseDelete'), + ); } } diff --git a/tests/parser/InsertStatementTest.php b/tests/parser/InsertStatementTest.php index bce6065..d63054c 100644 --- a/tests/parser/InsertStatementTest.php +++ b/tests/parser/InsertStatementTest.php @@ -1,10 +1,24 @@ <?php +namespace SqlParser\Tests\Parser; + +use SqlParser\Tests\TestCase; + class InsertStatementTest extends TestCase { - public function testInsert() + /** + * @dataProvider testInsertProvider + */ + public function testInsert($test) + { + $this->runParserTest($test); + } + + public function testInsertProvider() { - $this->runParserTest('parseInsert'); + return array( + array('parseInsert'), + ); } } diff --git a/tests/parser/ParserTest.php b/tests/parser/ParserTest.php index 8a77086..dc3475b 100644 --- a/tests/parser/ParserTest.php +++ b/tests/parser/ParserTest.php @@ -1,11 +1,15 @@ <?php +namespace SqlParser\Tests\Parser; + use SqlParser\Exceptions\ParserException; use SqlParser\Lexer; use SqlParser\Parser; use SqlParser\Token; use SqlParser\TokensList; +use SqlParser\Tests\TestCase; + class ParserTest extends TestCase { diff --git a/tests/parser/RenameStatementTest.php b/tests/parser/RenameStatementTest.php index 2ae608d..62ed19d 100644 --- a/tests/parser/RenameStatementTest.php +++ b/tests/parser/RenameStatementTest.php @@ -1,15 +1,25 @@ <?php +namespace SqlParser\Tests\Parser; + +use SqlParser\Tests\TestCase; + class RenameStatementTest extends TestCase { - public function testRename() + /** + * @dataProvider testRenameProvider + */ + public function testRename($test) { - $this->runParserTest('parseRename'); + $this->runParserTest($test); } - public function testRename2() + public function testRenameProvider() { - $this->runParserTest('parseRename2'); + return array( + array('parseRename'), + array('parseRename2'), + ); } } diff --git a/tests/parser/ReplaceStatementTest.php b/tests/parser/ReplaceStatementTest.php index 4366a15..8044a8f 100644 --- a/tests/parser/ReplaceStatementTest.php +++ b/tests/parser/ReplaceStatementTest.php @@ -1,15 +1,25 @@ <?php +namespace SqlParser\Tests\Parser; + +use SqlParser\Tests\TestCase; + class ReplaceStatementTest extends TestCase { - public function testReplace() + /** + * @dataProvider testReplaceProvider + */ + public function testReplace($test) { - $this->runParserTest('parseReplace'); + $this->runParserTest($test); } - public function testReplace2() + public function testReplaceProvider() { - $this->runParserTest('parseReplace2'); + return array( + array('parseReplace'), + array('parseReplace2'), + ); } } diff --git a/tests/parser/SelectStatementTest.php b/tests/parser/SelectStatementTest.php index 21df10f..943ceb7 100644 --- a/tests/parser/SelectStatementTest.php +++ b/tests/parser/SelectStatementTest.php @@ -1,27 +1,33 @@ <?php +namespace SqlParser\Tests\Parser; + +use SqlParser\Tests\TestCase; + class SelectStatementTest extends TestCase { - public function testSelect() + public function testSelectOptions() { $parser = $this->runParserTest('parseSelect'); $stmt = $parser->statements[0]; $this->assertEquals(10, $stmt->options->has('MAX_STATEMENT_TIME')); } - public function testSelect2() - { - $this->runParserTest('parseSelect2'); - } - - public function testSelectErr1() + /** + * @dataProvider testSelectProvider + */ + public function testSelect($test) { - $this->runParserTest('parseSelectErr1'); + $this->runParserTest($test); } - public function testSelectNested() + public function testSelectProvider() { - $this->runParserTest('parseSelectNested'); + return array( + array('parseSelect2'), + array('parseSelectErr1'), + array('parseSelectNested'), + ); } } diff --git a/tests/parser/UpdateStatementTest.php b/tests/parser/UpdateStatementTest.php index 882d9ac..0bb4df0 100644 --- a/tests/parser/UpdateStatementTest.php +++ b/tests/parser/UpdateStatementTest.php @@ -1,15 +1,25 @@ <?php +namespace SqlParser\Tests\Parser; + +use SqlParser\Tests\TestCase; + class UpdateStatementTest extends TestCase { - public function testUpdate() + /** + * @dataProvider testUpdateProvider + */ + public function testUpdate($test) { - $this->runParserTest('parseUpdate'); + $this->runParserTest($test); } - public function testUpdate2() + public function testUpdateProvider() { - $this->runParserTest('parseUpdate2'); + return array( + array('parseUpdate'), + array('parseUpdate2'), + ); } } diff --git a/tests/utils/MiscTest.php b/tests/utils/MiscTest.php index a1f5194..0b04d37 100644 --- a/tests/utils/MiscTest.php +++ b/tests/utils/MiscTest.php @@ -1,8 +1,12 @@ <?php +namespace SqlParser\Tests\Utils; + use SqlParser\Parser; use SqlParser\Utils\Misc; +use SqlParser\Tests\TestCase; + class MiscTest extends TestCase { @@ -82,5 +86,4 @@ class MiscTest extends TestCase ), ); } - } diff --git a/tests/utils/RoutineTest.php b/tests/utils/RoutineTest.php index 1f95c33..950f1cc 100644 --- a/tests/utils/RoutineTest.php +++ b/tests/utils/RoutineTest.php @@ -1,8 +1,12 @@ <?php +namespace SqlParser\Tests\Utils; + use SqlParser\Parser; use SqlParser\Utils\Routine; +use SqlParser\Tests\TestCase; + class RoutineTest extends TestCase { @@ -72,7 +76,8 @@ class RoutineTest extends TestCase ) ), array( - 'CREATE PROCEDURE `foo`(IN `baz\\` INT(001) zerofill, out bazz varchar(15) charset utf8) BEGIN SELECT NULL; END', + 'CREATE PROCEDURE `foo`(IN `baz\\` INT(001) zerofill, out bazz varchar(15) charset utf8) '. + 'BEGIN SELECT NULL; END', array( 'num' => 2, 'dir' => array( @@ -99,5 +104,4 @@ class RoutineTest extends TestCase ), ); } - } |