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