X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fpq-gateway;a=blobdiff_plain;f=tests%2Flib%2Fpq%2FGateway%2FCellTest.php;fp=tests%2Flib%2Fpq%2FGateway%2FCellTest.php;h=0afd0e3f4f2207bf91690341d780e796094c55b6;hp=0000000000000000000000000000000000000000;hb=e2709f3f6de6d5c5ba272d353db16b015b5258b3;hpb=4879955d1b86d606dc24401f26ebde9be7612fbf diff --git a/tests/lib/pq/Gateway/CellTest.php b/tests/lib/pq/Gateway/CellTest.php new file mode 100644 index 0000000..0afd0e3 --- /dev/null +++ b/tests/lib/pq/Gateway/CellTest.php @@ -0,0 +1,53 @@ +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); + } + + protected function tearDown() { + $this->conn->exec(PQ_TEST_DROP_TABLE); + } + + /** + * This is very bad test… + */ + public function testBasic() { + $row = $this->table->find(null, "id desc", 1)->current(); + foreach ($row->getData() as $key => $val) { + $this->assertEquals($val, (string) $row->$key); + $this->assertFalse($row->$key->isExpr()); + $this->assertFalse($row->$key->isDirty()); + $this->assertSame($val, $row->$key->get()); + $row->$key->mod(123); + $this->assertNotEquals($val, (string) $row->$key); + $this->assertTrue($row->$key->isExpr()); + $this->assertTrue($row->$key->isDirty()); + $this->assertNotSame($val, $row->$key->get()); + $this->assertEquals("$key + 123", (string) $row->$key->get()); + $row->$key->mod("foobar"); + $this->assertEquals("$key + 123 || 'foobar'", (string) $row->$key); + $row->$key->mod(new \pq\Query\Expr(" - %s()", "now")); + $this->assertEquals("$key + 123 || 'foobar' - now()", (string) $row->$key); + } + } +}