X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fpq-gateway;a=blobdiff_plain;f=tests%2Flib%2Fpq%2FGateway%2FTableTest.php;h=3f7b35c500ff8d004d726f735bf90026461ae999;hp=f3d955819c4e25ba6eeecf35c6e3064aa3431cf7;hb=409fca54acfee2db6c62540a8f67b1adfa695a38;hpb=3c8b32baaac62855e2c9f5bfdb5ede9685ce2b76 diff --git a/tests/lib/pq/Gateway/TableTest.php b/tests/lib/pq/Gateway/TableTest.php index f3d9558..3f7b35c 100644 --- a/tests/lib/pq/Gateway/TableTest.php +++ b/tests/lib/pq/Gateway/TableTest.php @@ -18,17 +18,14 @@ class TableTest extends \PHPUnit_Framework_TestCase { protected function setUp() { $this->conn = new \pq\Connection(PQ_TEST_DSN); - $this->conn->exec(PQ_TEST_TABLE_CREATE); - $this->conn->exec(PQ_TEST_REFTABLE_CREATE); - $this->conn->exec(PQ_TEST_DATA); + $this->conn->exec(PQ_TEST_SETUP_SQL); Table::$defaultConnection = $this->conn; $this->table = new Table("test"); $this->table->getQueryExecutor()->attach(new \QueryLogger()); } protected function tearDown() { - $this->conn->exec(PQ_TEST_REFTABLE_DROP); - $this->conn->exec(PQ_TEST_TABLE_DROP); + $this->conn->exec(PQ_TEST_TEARDOWN_SQL); } public function testSetRowsetPrototype() { @@ -70,14 +67,16 @@ class TableTest extends \PHPUnit_Framework_TestCase { public function testUpdate() { $row = $this->table->create(array())->current(); $data = array( - "created" => "2013-03-03 03:03:03", + "created" => new \pq\DateTime("2013-03-03 03:03:03"), "counter" => 2, "number" => 2.2, "data" => "this is a test", + "list" => array(3,2,1), + "prop" => null ); $row = $this->table->update(array("id = " => $row->id), $data)->current(); $data = array("id" => $row->id->get()) + $data; - $this->assertSame(array_map(function($v){return strval($v);}, $data), $row->getData()); + $this->assertEquals($data, $row->getData()); } public function testDelete() { @@ -91,10 +90,12 @@ class TableTest extends \PHPUnit_Framework_TestCase { $this->assertCount(1, $rowset); $this->assertEquals(array( "id" => 2, - "created" => date_create("today")->format("Y-m-d H:i:s"), + "created" => new \pq\DateTime("today"), "counter" => 0, "number" => 0, - "data" => "today" + "data" => "today", + "list" => array(0,1,2), + "prop" => null ), $rowset->current()->getData()); } }