X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Flib%2Fpq%2FGateway%2FRowTest.php;h=4d539a054d9ba5ae116080134a1e867e042758c0;hb=d1379696731e50755ace6e92fa04ae24fe34651b;hp=00dbbbb6c9c2eb806a877e3177adb1036d05ed54;hpb=580991717f5e8bb237403757e2111a8d04aca616;p=m6w6%2Fpq-gateway diff --git a/tests/lib/pq/Gateway/RowTest.php b/tests/lib/pq/Gateway/RowTest.php index 00dbbbb..4d539a0 100644 --- a/tests/lib/pq/Gateway/RowTest.php +++ b/tests/lib/pq/Gateway/RowTest.php @@ -2,7 +2,7 @@ namespace pq\Gateway; -include_once __DIR__."/../../../setup.inc"; +require_once __DIR__."/../../../setup.inc"; class RowTest extends \PHPUnit_Framework_TestCase { @@ -18,30 +18,29 @@ class RowTest 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); } function testBasic() { $row = new Row($this->table, array("id" => 3), true); $this->assertTrue($row->isDirty()); $row->refresh(); - $this->assertSame( + $this->assertEquals( array( "id" => "3", - "created" => date("Y-m-d H:i:s", strtotime("tomorrow")), + "created" => new \pq\DateTime("tomorrow"), "counter" => "1", "number" => "1.1", - "data" => "tomorrow" + "data" => "tomorrow", + "list" => array(1,2,3), + "prop" => null ), $row->getData() ); @@ -54,7 +53,7 @@ class RowTest extends \PHPUnit_Framework_TestCase { } function testPessimisticLock() { - $this->table->setLock(new Table\PessimisticLock); + $this->table->attach(new Table\PessimisticLock); $txn = $this->table->getConnection()->startTransaction(); $row = $this->table->find(null, null, 1)->current(); $row->data = "foo"; @@ -64,7 +63,7 @@ class RowTest extends \PHPUnit_Framework_TestCase { } function testPessimisticLockFail() { - $this->table->setLock(new Table\PessimisticLock); + $this->table->attach(new Table\PessimisticLock); $txn = $this->table->getConnection()->startTransaction(); $row = $this->table->find(null, null, 1)->current(); $row->data = "foo"; @@ -78,7 +77,7 @@ class RowTest extends \PHPUnit_Framework_TestCase { } function testOptimisticLock() { - $this->table->setLock(new Table\OptimisticLock("counter")); + $this->table->attach(new Table\OptimisticLock("counter")); $row = $this->table->find(null, null, 1)->current(); $cnt = $row->counter->get(); $row->data = "foo"; @@ -88,9 +87,8 @@ class RowTest extends \PHPUnit_Framework_TestCase { } function testOptimisticLockFail() { - $this->table->setLock(new Table\OptimisticLock("counter")); + $this->table->attach(new Table\OptimisticLock("counter")); $row = $this->table->find(null, null, 1)->current(); - $cnt = $row->counter->get(); $row->data = "foo"; executeInConcurrentTransaction( $this->table->getQueryExecutor(), @@ -102,8 +100,8 @@ class RowTest extends \PHPUnit_Framework_TestCase { function testRef() { foreach ($this->table->find() as $row) { - foreach ($row->reftest() as $ref) { - $this->assertEquals($row->id->get(), $ref->test->id->get()); + foreach ($row->allOf("reftest") as $ref) { + $this->assertEquals($row->id->get(), $ref->ofWhich("test")->current()->id->get()); } } }