10 use UnexpectedValueException
;
12 require_once __DIR__
."/../../../setup.inc";
14 class MapTest
extends \PHPUnit_Framework_TestCase
31 protected function setUp() {
32 $this->conn
= new Connection(PQ_TEST_DSN
);
33 $this->conn
->exec(PQ_TEST_SETUP_SQL
);
34 Table
::$defaultConnection = $this->conn
;
35 $this->mapper
= new Mapper
;
36 $this->map
= TestModel
::mapAs($this->mapper
);
39 protected function tearDown() {
40 $this->conn
->exec(PQ_TEST_TEARDOWN_SQL
);
44 $row = $this->map
->getGateway()->find(["id="=>1])->current();
45 $obj = $this->map
->map($row);
46 $this->assertEquals($row->data
->get(), $obj->data
);
49 function testUnmap() {
50 $obj = new \TestModel
;
51 $obj->data
= "this is a test";
52 $this->map
->unmap($obj);
53 $this->assertSame(4, $obj->id
);
56 function testUnmapRef() {
57 $obj = new \TestModel
;
58 $obj->ref1
= $obj->ref2
= [
61 $this->map
->unmap($obj);