| @@ 514-541 (lines=28) @@ | ||
| 511 | $this->assertTrue($result->isOK($msg)); |
|
| 512 | } |
|
| 513 | ||
| 514 | public function testMalformedMultiplicity() |
|
| 515 | { |
|
| 516 | $msg = null; |
|
| 517 | $metadataManager = new MetadataManager("Data", "Container"); |
|
| 518 | $result = null; |
|
| 519 | ||
| 520 | list($CategoryType, $result) = $metadataManager->addEntityType("Category"); |
|
| 521 | list($CustomerType, $result) = $metadataManager->addEntityType("Customer"); |
|
| 522 | $this->assertTrue($CategoryType->isOK($msg), $msg); |
|
| 523 | $this->assertTrue($CustomerType->isOK($msg), $msg); |
|
| 524 | ||
| 525 | $expected = "Malformed multiplicity - valid values are *, 0..1 and 1"; |
|
| 526 | $actual = null; |
|
| 527 | ||
| 528 | try { |
|
| 529 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
| 530 | $CategoryType, |
|
| 531 | "1", |
|
| 532 | "Customers", |
|
| 533 | $CustomerType, |
|
| 534 | "ABC", |
|
| 535 | "Categories" |
|
| 536 | ); |
|
| 537 | } catch (\InvalidArgumentException $e) { |
|
| 538 | $actual = $e->getMessage(); |
|
| 539 | } |
|
| 540 | $this->assertEquals($expected, $actual); |
|
| 541 | } |
|
| 542 | ||
| 543 | public function testInvalidMultiplicityBelongsOnBothEnds() |
|
| 544 | { |
|
| @@ 543-570 (lines=28) @@ | ||
| 540 | $this->assertEquals($expected, $actual); |
|
| 541 | } |
|
| 542 | ||
| 543 | public function testInvalidMultiplicityBelongsOnBothEnds() |
|
| 544 | { |
|
| 545 | $msg = null; |
|
| 546 | $metadataManager = new MetadataManager("Data", "Container"); |
|
| 547 | $result = null; |
|
| 548 | ||
| 549 | list($CategoryType, $result) = $metadataManager->addEntityType("Category"); |
|
| 550 | list($CustomerType, $result) = $metadataManager->addEntityType("Customer"); |
|
| 551 | $this->assertTrue($CategoryType->isOK($msg), $msg); |
|
| 552 | $this->assertTrue($CustomerType->isOK($msg), $msg); |
|
| 553 | ||
| 554 | $expected = "Invalid multiplicity combination - 1 1"; |
|
| 555 | $actual = null; |
|
| 556 | ||
| 557 | try { |
|
| 558 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
| 559 | $CategoryType, |
|
| 560 | "1", |
|
| 561 | "Customers", |
|
| 562 | $CustomerType, |
|
| 563 | "1", |
|
| 564 | "Categories" |
|
| 565 | ); |
|
| 566 | } catch (\InvalidArgumentException $e) { |
|
| 567 | $actual = $e->getMessage(); |
|
| 568 | } |
|
| 569 | $this->assertEquals($expected, $actual); |
|
| 570 | } |
|
| 571 | ||
| 572 | public function testInvalidMultiplicityManyToHasMany() |
|
| 573 | { |
|
| @@ 572-599 (lines=28) @@ | ||
| 569 | $this->assertEquals($expected, $actual); |
|
| 570 | } |
|
| 571 | ||
| 572 | public function testInvalidMultiplicityManyToHasMany() |
|
| 573 | { |
|
| 574 | $msg = null; |
|
| 575 | $metadataManager = new MetadataManager("Data", "Container"); |
|
| 576 | $result = null; |
|
| 577 | ||
| 578 | list($CategoryType, $result) = $metadataManager->addEntityType("Category"); |
|
| 579 | list($CustomerType, $result) = $metadataManager->addEntityType("Customer"); |
|
| 580 | $this->assertTrue($CategoryType->isOK($msg), $msg); |
|
| 581 | $this->assertTrue($CustomerType->isOK($msg), $msg); |
|
| 582 | ||
| 583 | $expected = "Invalid multiplicity combination - * 0..1"; |
|
| 584 | $actual = null; |
|
| 585 | ||
| 586 | try { |
|
| 587 | list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( |
|
| 588 | $CategoryType, |
|
| 589 | "*", |
|
| 590 | "Customers", |
|
| 591 | $CustomerType, |
|
| 592 | "0..1", |
|
| 593 | "Categories" |
|
| 594 | ); |
|
| 595 | } catch (\InvalidArgumentException $e) { |
|
| 596 | $actual = $e->getMessage(); |
|
| 597 | } |
|
| 598 | $this->assertEquals($expected, $actual); |
|
| 599 | } |
|
| 600 | } |
|
| 601 | ||