5 include __DIR__
."/../../../setup.inc";
7 class CellTest
extends \PHPUnit_Framework_TestCase
{
15 * @var \pq\Gateway\Table
19 protected function setUp() {
20 $this->conn
= new \pq\
Connection(PQ_TEST_DSN
);
21 $this->conn
->exec(PQ_TEST_TABLE_CREATE
);
22 $this->conn
->exec(PQ_TEST_REFTABLE_CREATE
);
23 $this->conn
->exec(PQ_TEST_DATA
);
24 Table
::$defaultConnection = $this->conn
;
25 $this->table
= new Table("test");
26 $this->table
->getQueryExecutor()->attach(new \
QueryLogger());
29 protected function tearDown() {
30 $this->conn
->exec(PQ_TEST_REFTABLE_DROP
);
31 $this->conn
->exec(PQ_TEST_TABLE_DROP
);
35 * This is a very bad test…
37 public function testBasic() {
38 $row = $this->table
->find(null, "id desc", 1)->current();
39 foreach ($row->getData() as $key => $val) {
40 $this->assertEquals($val, (string) $row->$key);
41 $this->assertFalse($row->$key->isExpr());
42 $this->assertFalse($row->$key->isDirty());
43 $this->assertSame($val, $row->$key->get());
45 $this->assertNotEquals($val, (string) $row->$key);
46 $this->assertTrue($row->$key->isExpr());
47 $this->assertTrue($row->$key->isDirty());
48 $this->assertNotSame($val, $row->$key->get());
49 $this->assertEquals("$key + 123", (string) $row->$key->get());
50 $row->$key->mod("foobar");
51 $this->assertEquals("$key + 123 || 'foobar'", (string) $row->$key);
52 $row->$key->mod(new \pq\Query\
Expr(" - %s()", "now"));
53 $this->assertEquals("$key + 123 || 'foobar' - now()", (string) $row->$key);