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_SETUP_SQL
);
22 Table
::$defaultConnection = $this->conn
;
23 $this->table
= new Table("test");
24 $this->table
->getQueryExecutor()->attach(new \
QueryLogger());
27 protected function tearDown() {
28 $this->conn
->exec(PQ_TEST_TEARDOWN_SQL
);
32 * This is a very bad test…
34 public function testBasic() {
35 $row = $this->table
->find(null, "id desc", 1)->current();
36 foreach ($row->getData() as $key => $val) {
37 $this->assertEquals($val, (string) $row->$key);
38 $this->assertFalse($row->$key->isExpr());
39 $this->assertFalse($row->$key->isDirty());
40 $this->assertSame($val, $row->$key->get());
42 $this->assertNotEquals($val, (string) $row->$key);
43 $this->assertTrue($row->$key->isExpr());
44 $this->assertTrue($row->$key->isDirty());
45 $this->assertNotSame($val, $row->$key->get());
46 $this->assertEquals("$key + 123", (string) $row->$key->get());
47 $row->$key->mod("foobar");
48 $this->assertEquals("$key + 123 || 'foobar'", (string) $row->$key);
49 $row->$key->mod(new \pq\Query\
Expr(" - %s()", "now"));
50 $this->assertEquals("$key + 123 || 'foobar' - now()", (string) $row->$key);