| @@ 481-516 (lines=36) @@ | ||
| 478 | * @expectedException Sensorario\Resources\Exceptions\PropertyNotSetException |
|
| 479 | * @expectedExceptionMessageRegExp #Property `.*::.*` is mandatory but not set# |
|
| 480 | */ |
|
| 481 | public function testDependentMandatoryProperties() |
|
| 482 | { |
|
| 483 | $configurator = new Configurator( |
|
| 484 | 'foo', |
|
| 485 | new Container([ |
|
| 486 | 'resources' => [ |
|
| 487 | 'foo' => [ |
|
| 488 | 'constraints' => [ |
|
| 489 | 'allowed' => [ |
|
| 490 | 'bar', |
|
| 491 | ], |
|
| 492 | 'mandatory' => [ |
|
| 493 | 'mandatory_property_name', |
|
| 494 | 'foo' => [ |
|
| 495 | 'when' => [ |
|
| 496 | 'property' => 'bar', |
|
| 497 | 'condition' => 'is_present', |
|
| 498 | ] |
|
| 499 | ], |
|
| 500 | ], |
|
| 501 | ] |
|
| 502 | ], |
|
| 503 | ], |
|
| 504 | ]) |
|
| 505 | ); |
|
| 506 | ||
| 507 | $properties = [ |
|
| 508 | 'mandatory_property_name' => '42', |
|
| 509 | 'bar' => 'beer', |
|
| 510 | ]; |
|
| 511 | ||
| 512 | Resource::box( |
|
| 513 | $properties, |
|
| 514 | $configurator |
|
| 515 | ); |
|
| 516 | } |
|
| 517 | ||
| 518 | public function testMandatoryConstraintsAreAutomaticallyAllowed() |
|
| 519 | { |
|
| @@ 722-756 (lines=35) @@ | ||
| 719 | /** |
|
| 720 | * @expectedException Sensorario\Resources\Exceptions\PropertyException |
|
| 721 | */ |
|
| 722 | public function testHasMandatoryPropertiesWhenAnotherOneHasAParticularValue() |
|
| 723 | { |
|
| 724 | $configurator = new Configurator( |
|
| 725 | 'foo', |
|
| 726 | new Container([ |
|
| 727 | 'resources' => [ |
|
| 728 | 'foo' => [ |
|
| 729 | 'constraints' => [ |
|
| 730 | 'allowed' => [ |
|
| 731 | 'bar', |
|
| 732 | ], |
|
| 733 | 'mandatory' => [ |
|
| 734 | 'mandatory_property_name', |
|
| 735 | 'foo' => [ |
|
| 736 | 'when' => [ |
|
| 737 | 'property' => 'bar', |
|
| 738 | 'has_value' => '42', |
|
| 739 | ] |
|
| 740 | ], |
|
| 741 | ], |
|
| 742 | ] |
|
| 743 | ], |
|
| 744 | ], |
|
| 745 | ]) |
|
| 746 | ); |
|
| 747 | ||
| 748 | $properties = [ |
|
| 749 | 'bar' => '42', |
|
| 750 | ]; |
|
| 751 | ||
| 752 | Resource::box( |
|
| 753 | $properties, |
|
| 754 | $configurator |
|
| 755 | ); |
|
| 756 | } |
|
| 757 | ||
| 758 | /** |
|
| 759 | * @expectedException Sensorario\Resources\Exceptions\EmailException |
|