1: <?php
2:
3: namespace Alchemy\tests;
4: use Alchemy\util\DataTypeLexer;
5:
6:
7: class DataTypeLexerTest extends BaseTest {
8:
9: public function testLexer() {
10: $type = new DataTypeLexer("String");
11: $this->assertEquals("String", $type->getType());
12: $this->assertEquals(array(), $type->getArgs());
13:
14: $type = new DataTypeLexer("String()");
15: $this->assertEquals("String", $type->getType());
16: $this->assertEquals(array(), $type->getArgs());
17:
18: $type = new DataTypeLexer("Integer(11)");
19: $this->assertEquals("Integer", $type->getType());
20: $this->assertEquals(array(11), $type->getArgs());
21:
22: $type = new DataTypeLexer("Integer(11, primary_key = true)");
23: $this->assertEquals("Integer", $type->getType());
24: $this->assertEquals(array(11, 'primary_key' => true), $type->getArgs());
25:
26: $type = new DataTypeLexer("Integer(10, foreign_key='Table.ColumnID')");
27: $this->assertEquals("Integer", $type->getType());
28: $this->assertEquals(array(10, 'foreign_key' => 'Table.ColumnID'), $type->getArgs());
29:
30: $type = new DataTypeLexer("ForeignKey([.Key1, .Key2], [Foreign.PK1, Foreign.PK2], ondelete = cascade)");
31: $this->assertEquals("ForeignKey", $type->getType());
32: $this->assertEquals(array(array('.Key1', '.Key2'), array('Foreign.PK1', 'Foreign.PK2'), 'ondelete' => 'cascade'), $type->getArgs());
33: }
34: }
35: