1: <?php
2:
3: namespace Alchemy\tests;
4: use Alchemy\core\schema\Table;
5: use Alchemy\core\query\Query;
6: use Alchemy\core\query\Scalar;
7:
8:
9: class InsertTest 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)
27: ->row("user1")
28: ->row("user2");
29:
30: $query->Email = "user1@example.com";
31:
32: $params = array(new Scalar("user1@example.com"), new Scalar("user1"), new Scalar("user2"));
33: $this->assertEquals($params, $query->parameters());
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: $params = array(new Scalar("user1@example.com"));
44: $this->assertEquals($params, $query->parameters());
45: }
46: }
47: