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