protected $table;
protected function setUp() {
- $this->conn = new \pq\Connection(PQ_DSN);
- $this->conn->exec(PQ_TEST_DROP_TABLE);
- $this->conn->exec(PQ_TEST_CREATE_TABLE);
- $this->conn->exec(PQ_TEST_CREATE_DATA);
- $this->table = new Table(PQ_TEST_TABLE_NAME, $this->conn);
+ $this->conn = new \pq\Connection(PQ_TEST_DSN);
+ $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_DROP_TABLE);
+ $this->conn->exec(PQ_TEST_TEARDOWN_SQL);
}
/**
- * This is very bad test…
+ * This is a very bad test…
*/
public function testBasic() {
$row = $this->table->find(null, "id desc", 1)->current();
$this->assertEquals("$key + 123 || 'foobar' - now()", (string) $row->$key);
}
}
+
+ public function testRef() {
+ $rows = $this->table->find(null, "id desc", 2);
+ $reft = new Table("reftest");
+ $refs = new Rowset($reft);
+ $refs->append($rows->seek(0)->current()->reftest()->current());
+ $refs->append($rows->seek(1)->current()->reftest()->current());
+ $refs->seek(0)->current()->test = $rows->seek(1)->current();
+ $refs->seek(1)->current()->test = $rows->seek(0)->current();
+ $refs->update();
+ }
}