diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Builder/CreateStatementTest.php | 11 | ||||
-rw-r--r-- | tests/Builder/SelectStatementTest.php | 19 | ||||
-rw-r--r-- | tests/Components/CreateDefinitionTest.php | 11 |
3 files changed, 30 insertions, 11 deletions
diff --git a/tests/Builder/CreateStatementTest.php b/tests/Builder/CreateStatementTest.php index 7ef247c..ecb0d02 100644 --- a/tests/Builder/CreateStatementTest.php +++ b/tests/Builder/CreateStatementTest.php @@ -203,4 +203,15 @@ class CreateStatementTest extends TestCase $stmt->build() ); } + + public function testBuildSelect() + { + $parser = new Parser( + 'CREATE TABLE new_tbl SELECT * FROM orig_tbl' + ); + $this->assertEquals( + 'CREATE TABLE new_tbl SELECT * FROM orig_tbl ', + $parser->statements[0]->build() + ); + } } diff --git a/tests/Builder/SelectStatementTest.php b/tests/Builder/SelectStatementTest.php index c36150a..492d212 100644 --- a/tests/Builder/SelectStatementTest.php +++ b/tests/Builder/SelectStatementTest.php @@ -34,4 +34,23 @@ class SelectStatementTest extends TestCase $stmt->build() ); } + + public function testBuilderAlias() + { + $parser = new Parser( + 'SELECT sgu.id, sgu.email_address FROM `sf_guard_user` sgu ' + . 'RIGHT JOIN `student_course_booking` scb ON sgu.id = scb.user_id ' + . 'WHERE `has_found_course` = \'1\' GROUP BY sgu.id ' + . 'ORDER BY scb.id DESC LIMIT 0,300' + ); + $stmt = $parser->statements[0]; + + $this->assertEquals( + 'SELECT sgu.id, sgu.email_address FROM `sf_guard_user` AS `sgu` ' + . 'RIGHT JOIN `student_course_booking` AS `scb` ON sgu.id = scb.user_id ' + . 'WHERE `has_found_course` = \'1\' GROUP BY sgu.id ASC ' + . 'ORDER BY scb.id DESC LIMIT 300 ', + $stmt->build() + ); + } } diff --git a/tests/Components/CreateDefinitionTest.php b/tests/Components/CreateDefinitionTest.php index 4d0094d..a7b7f86 100644 --- a/tests/Components/CreateDefinitionTest.php +++ b/tests/Components/CreateDefinitionTest.php @@ -64,15 +64,4 @@ class CreateDefinitionTest extends TestCase CreateDefinition::build($parser->statements[0]->fields[1]) ); } - - public function testBuildSelect() - { - $parser = new Parser( - 'CREATE TABLE new_tbl SELECT * FROM orig_tbl' - ); - $this->assertEquals( - 'CREATE TABLE new_tbl SELECT * FROM orig_tbl ', - $parser->statements[0]->build() - ); - } } |