a73ddd48bd989da33e2b49499d5a742768d04a76
[m6w6/pq-gateway] / tests / lib / pq / Mapper / ObjectManagerTest.php
1 <?php
2
3 namespace pq\Mapper;
4
5 require_once __DIR__."/../../../setup.inc";
6
7 use pq\Connection;
8 use pq\Gateway\Table;
9 use pq\Mapper\ObjectManager;
10 use QueryLogger;
11 use TestModel;
12
13 class ObjectManagerTest extends \PHPUnit_Framework_TestCase
14 {
15 /**
16 * @var Connection
17 */
18 protected $conn;
19 /**
20 * @var ObjectManager
21 */
22 protected $objectManager;
23
24 /**
25 * Sets up the fixture, for example, opens a network connection.
26 * This method is called before a test is executed.
27 */
28 protected function setUp() {
29 $this->conn = new Connection(PQ_TEST_DSN);
30 $this->conn->exec(PQ_TEST_SETUP_SQL);
31 Table::$defaultConnection = $this->conn;
32 $mapper = new Mapper;
33 $mapping = TestModel::mapAs($mapper);
34 $mapping->getGateway()->getQueryExecutor()->attach(new QueryLogger());
35 $this->objectManager = new ObjectManager($mapping);
36 }
37
38 /**
39 * Tears down the fixture, for example, closes a network connection.
40 * This method is called after a test is executed.
41 */
42 protected function tearDown() {
43
44 }
45
46 public function testBasic() {
47 $row = $this->objectManager->getMap()->getGateway()->find(["id="=>1])->current();
48 $row_id = $this->objectManager->rowId($row);
49 $this->assertFalse($this->objectManager->hasObject($row_id));
50 $this->objectManager->createObject($row);
51 $this->assertTrue($this->objectManager->hasObject($row_id));
52 $this->objectManager->reset();
53 $this->assertFalse($this->objectManager->hasObject($row_id));
54 }
55
56 /**
57 * @covers pq\Mapper\ObjectManager::rowId
58 * @todo Implement testRowId().
59 */
60 public function testRowId() {
61 // Remove the following lines when you implement this test.
62 $this->markTestIncomplete(
63 'This test has not been implemented yet.'
64 );
65 }
66
67 /**
68 * @covers pq\Mapper\ObjectManager::objectId
69 * @todo Implement testObjectId().
70 */
71 public function testObjectId() {
72 // Remove the following lines when you implement this test.
73 $this->markTestIncomplete(
74 'This test has not been implemented yet.'
75 );
76 }
77
78 /**
79 * @covers pq\Mapper\ObjectManager::extractRowId
80 * @todo Implement testExtractRowId().
81 */
82 public function testExtractRowId() {
83 // Remove the following lines when you implement this test.
84 $this->markTestIncomplete(
85 'This test has not been implemented yet.'
86 );
87 }
88
89 /**
90 * @covers pq\Mapper\ObjectManager::serializeRowId
91 * @todo Implement testSerializeRowId().
92 */
93 public function testSerializeRowId() {
94 // Remove the following lines when you implement this test.
95 $this->markTestIncomplete(
96 'This test has not been implemented yet.'
97 );
98 }
99
100 /**
101 * @covers pq\Mapper\ObjectManager::hasObject
102 * @todo Implement testHasObject().
103 */
104 public function testHasObject() {
105 // Remove the following lines when you implement this test.
106 $this->markTestIncomplete(
107 'This test has not been implemented yet.'
108 );
109 }
110
111 /**
112 * @covers pq\Mapper\ObjectManager::createObject
113 * @todo Implement testCreateObject().
114 */
115 public function testCreateObject() {
116 // Remove the following lines when you implement this test.
117 $this->markTestIncomplete(
118 'This test has not been implemented yet.'
119 );
120 }
121
122 /**
123 * @covers pq\Mapper\ObjectManager::resetObject
124 * @todo Implement testResetObject().
125 */
126 public function testResetObject() {
127 // Remove the following lines when you implement this test.
128 $this->markTestIncomplete(
129 'This test has not been implemented yet.'
130 );
131 }
132
133 /**
134 * @covers pq\Mapper\ObjectManager::getObject
135 * @todo Implement testGetObject().
136 */
137 public function testGetObject() {
138 // Remove the following lines when you implement this test.
139 $this->markTestIncomplete(
140 'This test has not been implemented yet.'
141 );
142 }
143
144 /**
145 * @covers pq\Mapper\ObjectManager::getObjectById
146 * @todo Implement testGetObjectById().
147 */
148 public function testGetObjectById() {
149 // Remove the following lines when you implement this test.
150 $this->markTestIncomplete(
151 'This test has not been implemented yet.'
152 );
153 }
154
155 /**
156 * @covers pq\Mapper\ObjectManager::asObject
157 * @todo Implement testAsObject().
158 */
159 public function testAsObject() {
160 // Remove the following lines when you implement this test.
161 $this->markTestIncomplete(
162 'This test has not been implemented yet.'
163 );
164 }
165
166 /**
167 * @covers pq\Mapper\ObjectManager::hasRow
168 * @todo Implement testHasRow().
169 */
170 public function testHasRow() {
171 // Remove the following lines when you implement this test.
172 $this->markTestIncomplete(
173 'This test has not been implemented yet.'
174 );
175 }
176
177 /**
178 * @covers pq\Mapper\ObjectManager::createRow
179 * @todo Implement testCreateRow().
180 */
181 public function testCreateRow() {
182 // Remove the following lines when you implement this test.
183 $this->markTestIncomplete(
184 'This test has not been implemented yet.'
185 );
186 }
187
188 /**
189 * @covers pq\Mapper\ObjectManager::resetRow
190 * @todo Implement testResetRow().
191 */
192 public function testResetRow() {
193 // Remove the following lines when you implement this test.
194 $this->markTestIncomplete(
195 'This test has not been implemented yet.'
196 );
197 }
198
199 /**
200 * @covers pq\Mapper\ObjectManager::getRow
201 * @todo Implement testGetRow().
202 */
203 public function testGetRow() {
204 // Remove the following lines when you implement this test.
205 $this->markTestIncomplete(
206 'This test has not been implemented yet.'
207 );
208 }
209
210 /**
211 * @covers pq\Mapper\ObjectManager::asRow
212 * @todo Implement testAsRow().
213 */
214 public function testAsRow() {
215 // Remove the following lines when you implement this test.
216 $this->markTestIncomplete(
217 'This test has not been implemented yet.'
218 );
219 }
220
221 }