28d2728c006817ad09e59470d492ed8abf93d666
[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_DSN);
21 $this->conn->exec(PQ_TEST_DROP_TABLE);
22 $this->conn->exec(PQ_TEST_CREATE_TABLE);
23 $this->conn->exec(PQ_TEST_CREATE_DATA);
24
25 $this->table = new Table(PQ_TEST_TABLE_NAME, $this->conn);
26 }
27
28 protected function tearDown() {
29 $this->conn->exec(PQ_TEST_DROP_TABLE);
30 }
31
32 function testBasic() {
33 $row = new Row($this->table, array("id" => 3), true);
34 $this->assertTrue($row->isDirty());
35 $row->refresh();
36 $this->assertSame(
37 array(
38 "id" => "3",
39 "created" => date("Y-m-d H:i:s", strtotime("tomorrow")),
40 "counter" => "1",
41 "number" => "1.1",
42 "data" => "tomorrow"
43 ),
44 $row->getData()
45 );
46 $this->assertFalse($row->isDirty());
47 }
48
49 function testGetTable() {
50 $row = new Row($this->table);
51 $this->assertSame($this->table, $row->getTable());
52 }
53 }