summaryrefslogtreecommitdiffstats
path: root/tests/Components/FieldDefinitionTest.php
diff options
context:
space:
mode:
authorDan Ungureanu <udan1107@gmail.com>2015-07-15 00:19:14 +0300
committerDan Ungureanu <udan1107@gmail.com>2015-07-15 00:19:14 +0300
commitd8c6b9cc361a610ef04df9d86b61aabbb68eacb3 (patch)
treed9e6ab71497b777fc58fc1715315e56ccd934684 /tests/Components/FieldDefinitionTest.php
parent380603a8bfebd612bbc70801d99eb727be3e36ce (diff)
downloadsql-parser-d8c6b9cc361a610ef04df9d86b61aabbb68eacb3.zip
sql-parser-d8c6b9cc361a610ef04df9d86b61aabbb68eacb3.tar.gz
sql-parser-d8c6b9cc361a610ef04df9d86b61aabbb68eacb3.tar.bz2
Improved error messages.
Achieved 100% code coverage. Some refactoring.
Diffstat (limited to 'tests/Components/FieldDefinitionTest.php')
-rw-r--r--tests/Components/FieldDefinitionTest.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/Components/FieldDefinitionTest.php b/tests/Components/FieldDefinitionTest.php
new file mode 100644
index 0000000..11cac32
--- /dev/null
+++ b/tests/Components/FieldDefinitionTest.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace SqlParser\Tests\Components;
+
+use SqlParser\Parser;
+use SqlParser\Components\FieldDefinition;
+
+use SqlParser\Tests\TestCase;
+
+class FieldDefinitionTest extends TestCase
+{
+
+ public function testParse()
+ {
+ $component = FieldDefinition::parse(
+ new Parser(),
+ $this->getTokensList('(str TEXT, FULLTEXT INDEX indx (str)')
+ );
+ $this->assertEquals('str', $component[0]->name);
+ $this->assertEquals('FULLTEXT INDEX', $component[1]->key->type);
+ $this->assertEquals('indx', $component[1]->key->name);
+ $this->assertEquals('FULLTEXT INDEX `indx` (`str`)', $component[1]);
+ }
+
+ public function testBuild() {
+ $parser = new Parser(
+ 'CREATE TABLE `payment` (' .
+ '-- snippet' . "\n" .
+ '`customer_id` smallint(5) unsigned NOT NULL,' .
+ 'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE,' .
+ ') ENGINE=InnoDB")'
+ );
+ $this->assertEquals(
+ 'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE',
+ FieldDefinition::build($parser->statements[0]->fields[1])
+ );
+ }
+}