X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fpq-gateway;a=blobdiff_plain;f=tests%2Flib%2Fpq%2FGateway%2FCellTest.php;h=9235a39ec81487278d4ecb79494384505f33088f;hp=0afd0e3f4f2207bf91690341d780e796094c55b6;hb=b39e14404cfeac177d41b152690b6adbb2b1e4bf;hpb=e2709f3f6de6d5c5ba272d353db16b015b5258b3 diff --git a/tests/lib/pq/Gateway/CellTest.php b/tests/lib/pq/Gateway/CellTest.php index 0afd0e3..9235a39 100644 --- a/tests/lib/pq/Gateway/CellTest.php +++ b/tests/lib/pq/Gateway/CellTest.php @@ -17,19 +17,19 @@ class CellTest extends \PHPUnit_Framework_TestCase { 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(); @@ -50,4 +50,15 @@ class CellTest extends \PHPUnit_Framework_TestCase { $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(); + } }