fc0809468ea0a7aa2f804de834263ab8c410e5ab
[m6w6/pq-gateway] / tests / lib / pq / Gateway / RowTest.php
1 <?php
2
3 namespace pq\Gateway;
4
5 include_once __DIR__."/../../../setup.inc";
6
7 class RowTest extends \PHPUnit_Framework_TestCase {
8
9 /**
10 * @var \pq\Connection
11 */
12 protected $conn;
13
14 /**
15 * @var \pq\Gateway\Table
16 */
17 protected $table;
18
19 protected function setUp() {
20 $this->conn = new \pq\Connection(PQ_TEST_DSN);
21 $this->conn->exec(PQ_TEST_TABLE_CREATE);
22 $this->conn->exec(PQ_TEST_REFTABLE_CREATE);
23 $this->conn->exec(PQ_TEST_DATA);
24 Table::$defaultConnection = $this->conn;
25 $this->table = new Table("test");
26 }
27
28 protected function tearDown() {
29 $this->conn->exec(PQ_TEST_REFTABLE_DROP);
30 $this->conn->exec(PQ_TEST_TABLE_DROP);
31 }
32
33 function testBasic() {
34 $row = new Row($this->table, array("id" => 3), true);
35 $this->assertTrue($row->isDirty());
36 $row->refresh();
37 $this->assertSame(
38 array(
39 "id" => "3",
40 "created" => date("Y-m-d H:i:s", strtotime("tomorrow")),
41 "counter" => "1",
42 "number" => "1.1",
43 "data" => "tomorrow"
44 ),
45 $row->getData()
46 );
47 $this->assertFalse($row->isDirty());
48 }
49
50 function testGetTable() {
51 $row = new Row($this->table);
52 $this->assertSame($this->table, $row->getTable());
53 }
54 }