1: <?php
2:
3: namespace Alchemy\tests;
4: use Alchemy\core\schema\Table;
5: use Alchemy\core\query\Query;
6: use Alchemy\dialect\ANSICompiler;
7:
8:
9: class ANSIInsertTest extends BaseTest {
10:
11: protected $users;
12:
13: public function setUp() {
14: $this->users = Table::Core('users', array(
15: 'columns' => array(
16: 'UserID' => 'Integer(11)',
17: 'UserName' => 'String',
18: 'Email' => 'String')
19: ));
20: }
21:
22: public function testSimpleInsert() {
23: $users = $this->users->getRef();
24:
25: $query = Query::Insert($users)
26: ->columns($users->UserName, array('Email', "user1@example.com"))
27: ->row("user1")
28: ->row("user2");
29:
30: $ansi = new ANSICompiler();
31: $vern = $ansi->compile($query);
32:
33: $this->assertExpectedString('ANSIInsertTest-1.sql', $vern);
34: }
35:
36: public function testInsertSelect() {
37: $users = $this->users->getRef();
38:
39: $query = Query::Insert($users)
40: ->columns($users->UserName);
41: $query->Email = "user1@example.com";
42:
43: $ansi = new ANSICompiler();
44: $vern = $ansi->compile($query);
45:
46: $this->assertExpectedString('ANSIInsertTest-2.sql', $vern);
47: }
48: }
49: