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