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);
}
function testBasic() {
$row = new Row($this->table, array("id" => 3), true);
$this->assertTrue($row->isDirty());
$row->refresh();
- $this->assertSame(
+ $this->assertEquals(
array(
"id" => "3",
- "created" => date("Y-m-d H:i:s", strtotime("tomorrow")),
+ "created" => new \pq\DateTime("tomorrow"),
"counter" => "1",
"number" => "1.1",
- "data" => "tomorrow"
+ "data" => "tomorrow",
+ "list" => array(1,2,3),
+ "prop" => null
),
$row->getData()
);
function testOptimisticLockFail() {
$this->table->setLock(new Table\OptimisticLock("counter"));
$row = $this->table->find(null, null, 1)->current();
- $cnt = $row->counter->get();
$row->data = "foo";
executeInConcurrentTransaction(
$this->table->getQueryExecutor(),
function testRef() {
foreach ($this->table->find() as $row) {
foreach ($row->reftest() as $ref) {
- $this->assertEquals($row->id->get(), $ref->test->id->get());
+ $this->assertEquals($row->id->get(), $ref->test->current()->id->get());
}
}
}