@@ 225-257 (lines=33) @@ | ||
222 | $this->assertEquals('*', $dependentEnd->getMultiplicity()); |
|
223 | } |
|
224 | ||
225 | public function testAddOneToManyNavProperty() |
|
226 | { |
|
227 | list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); |
|
228 | ||
229 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
230 | $CategoryType, |
|
231 | '*', |
|
232 | 'custom', |
|
233 | $CustomerType, |
|
234 | '1', |
|
235 | 'categor' |
|
236 | ); |
|
237 | $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); |
|
238 | $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); |
|
239 | $this->assertEquals('custom', $principal->getName()); |
|
240 | $this->assertEquals('categor', $dependent->getName()); |
|
241 | ||
242 | $navProps = [$principal, $dependent]; |
|
243 | $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); |
|
244 | $this->assertEquals(1, count($assoc)); |
|
245 | $assoc = $assoc[0]; |
|
246 | $this->assertTrue($assoc instanceof TAssociationType); |
|
247 | $this->assertTrue($assoc->isOK($msg), $msg); |
|
248 | ||
249 | $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); |
|
250 | $ends = $assoc->getEnd(); |
|
251 | ||
252 | $this->assertEquals(2, count($ends)); |
|
253 | $this->checkNavProps($navProps, $ends); |
|
254 | list($principalEnd, $dependentEnd) = $this->figureOutEnds($ends, $principal, $dependent); |
|
255 | $this->assertEquals('*', $principalEnd->getMultiplicity()); |
|
256 | $this->assertEquals('1', $dependentEnd->getMultiplicity()); |
|
257 | } |
|
258 | ||
259 | public function testAddManyToOneNavProperty() |
|
260 | { |
|
@@ 259-291 (lines=33) @@ | ||
256 | $this->assertEquals('1', $dependentEnd->getMultiplicity()); |
|
257 | } |
|
258 | ||
259 | public function testAddManyToOneNavProperty() |
|
260 | { |
|
261 | list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); |
|
262 | ||
263 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
264 | $CategoryType, |
|
265 | '1', |
|
266 | 'custom', |
|
267 | $CustomerType, |
|
268 | '*', |
|
269 | 'categor' |
|
270 | ); |
|
271 | $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); |
|
272 | $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); |
|
273 | $this->assertEquals('custom', $principal->getName()); |
|
274 | $this->assertEquals('categor', $dependent->getName()); |
|
275 | ||
276 | $navProps = [$principal, $dependent]; |
|
277 | $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); |
|
278 | $this->assertEquals(1, count($assoc)); |
|
279 | $assoc = $assoc[0]; |
|
280 | $this->assertTrue($assoc instanceof TAssociationType); |
|
281 | $this->assertTrue($assoc->isOK($msg), $msg); |
|
282 | ||
283 | $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); |
|
284 | $ends = $assoc->getEnd(); |
|
285 | ||
286 | $this->assertEquals(2, count($ends)); |
|
287 | $this->checkNavProps($navProps, $ends); |
|
288 | list($principalEnd, $dependentEnd) = $this->figureOutEnds($ends, $principal, $dependent); |
|
289 | $this->assertEquals('1', $principalEnd->getMultiplicity()); |
|
290 | $this->assertEquals('*', $dependentEnd->getMultiplicity()); |
|
291 | } |
|
292 | ||
293 | public function testAddOneToOneForwardNavProperty() |
|
294 | { |
|
@@ 293-325 (lines=33) @@ | ||
290 | $this->assertEquals('*', $dependentEnd->getMultiplicity()); |
|
291 | } |
|
292 | ||
293 | public function testAddOneToOneForwardNavProperty() |
|
294 | { |
|
295 | list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); |
|
296 | ||
297 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
298 | $CategoryType, |
|
299 | '0..1', |
|
300 | 'custom', |
|
301 | $CustomerType, |
|
302 | '1', |
|
303 | 'categor' |
|
304 | ); |
|
305 | $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); |
|
306 | $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); |
|
307 | $this->assertEquals('custom', $principal->getName()); |
|
308 | $this->assertEquals('categor', $dependent->getName()); |
|
309 | ||
310 | $navProps = [$principal, $dependent]; |
|
311 | $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); |
|
312 | $this->assertEquals(1, count($assoc)); |
|
313 | $assoc = $assoc[0]; |
|
314 | $this->assertTrue($assoc instanceof TAssociationType); |
|
315 | $this->assertTrue($assoc->isOK($msg), $msg); |
|
316 | ||
317 | $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); |
|
318 | $ends = $assoc->getEnd(); |
|
319 | ||
320 | $this->assertEquals(2, count($ends)); |
|
321 | $this->checkNavProps($navProps, $ends); |
|
322 | list($principalEnd, $dependentEnd) = $this->figureOutEnds($ends, $principal, $dependent); |
|
323 | $this->assertEquals('0..1', $principalEnd->getMultiplicity()); |
|
324 | $this->assertEquals('1', $dependentEnd->getMultiplicity()); |
|
325 | } |
|
326 | ||
327 | public function testAddOneToOneReverseNavProperty() |
|
328 | { |
|
@@ 327-359 (lines=33) @@ | ||
324 | $this->assertEquals('1', $dependentEnd->getMultiplicity()); |
|
325 | } |
|
326 | ||
327 | public function testAddOneToOneReverseNavProperty() |
|
328 | { |
|
329 | list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); |
|
330 | ||
331 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
332 | $CategoryType, |
|
333 | '1', |
|
334 | 'custom', |
|
335 | $CustomerType, |
|
336 | '0..1', |
|
337 | 'categor' |
|
338 | ); |
|
339 | $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); |
|
340 | $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); |
|
341 | $this->assertEquals('custom', $principal->getName()); |
|
342 | $this->assertEquals('categor', $dependent->getName()); |
|
343 | ||
344 | $navProps = [$principal, $dependent]; |
|
345 | $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); |
|
346 | $this->assertEquals(1, count($assoc)); |
|
347 | $assoc = $assoc[0]; |
|
348 | $this->assertTrue($assoc instanceof TAssociationType); |
|
349 | $this->assertTrue($assoc->isOK($msg), $msg); |
|
350 | ||
351 | $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); |
|
352 | $ends = $assoc->getEnd(); |
|
353 | ||
354 | $this->assertEquals(2, count($ends)); |
|
355 | $this->checkNavProps($navProps, $ends); |
|
356 | list($principalEnd, $dependentEnd) = $this->figureOutEnds($ends, $principal, $dependent); |
|
357 | $this->assertEquals('1', $principalEnd->getMultiplicity()); |
|
358 | $this->assertEquals('0..1', $dependentEnd->getMultiplicity()); |
|
359 | } |
|
360 | ||
361 | public function testMetadataSerialiseRoundTrip() |
|
362 | { |