ensure accessing a cell on ref update
[m6w6/pq-gateway] / tests / lib / pq / Gateway / CellTest.php
index 9dc96805f0dda5855d63f8e425ab4b0c5f3002c2..9235a39ec81487278d4ecb79494384505f33088f 100644 (file)
@@ -18,17 +18,14 @@ class CellTest 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);
        }
 
        /**
@@ -53,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();
+       }
 }