| @@ 380-415 (lines=36) @@ | ||
| 377 | * @expectedException RuntimeException |
|
| 378 | * @expectedExceptionMessageRegExp #Property `.*::.*` is mandatory but not set# |
|
| 379 | */ |
|
| 380 | public function testDependentMandatoryProperties() |
|
| 381 | { |
|
| 382 | $configurator = new Configurator( |
|
| 383 | 'foo', |
|
| 384 | new Container([ |
|
| 385 | 'resources' => [ |
|
| 386 | 'foo' => [ |
|
| 387 | 'constraints' => [ |
|
| 388 | 'allowed' => [ |
|
| 389 | 'bar', |
|
| 390 | ], |
|
| 391 | 'mandatory' => [ |
|
| 392 | 'mandatory_property_name', |
|
| 393 | 'foo' => [ |
|
| 394 | 'when' => [ |
|
| 395 | 'property' => 'bar', |
|
| 396 | 'condition' => 'is_present', |
|
| 397 | ] |
|
| 398 | ], |
|
| 399 | ], |
|
| 400 | ] |
|
| 401 | ], |
|
| 402 | ], |
|
| 403 | ]) |
|
| 404 | ); |
|
| 405 | ||
| 406 | $properties = [ |
|
| 407 | 'mandatory_property_name' => '42', |
|
| 408 | 'bar' => 'beer', |
|
| 409 | ]; |
|
| 410 | ||
| 411 | Resource::box( |
|
| 412 | $properties, |
|
| 413 | $configurator |
|
| 414 | ); |
|
| 415 | } |
|
| 416 | ||
| 417 | public function testMandatoryConstraintsAreAutomaticallyAllowed() |
|
| 418 | { |
|
| @@ 621-655 (lines=35) @@ | ||
| 618 | /** |
|
| 619 | * @expectedException RuntimeException |
|
| 620 | */ |
|
| 621 | public function testHasMandatoryPropertiesWhenAnotherOneHasAParticularValue() |
|
| 622 | { |
|
| 623 | $configurator = new Configurator( |
|
| 624 | 'foo', |
|
| 625 | new Container([ |
|
| 626 | 'resources' => [ |
|
| 627 | 'foo' => [ |
|
| 628 | 'constraints' => [ |
|
| 629 | 'allowed' => [ |
|
| 630 | 'bar', |
|
| 631 | ], |
|
| 632 | 'mandatory' => [ |
|
| 633 | 'mandatory_property_name', |
|
| 634 | 'foo' => [ |
|
| 635 | 'when' => [ |
|
| 636 | 'property' => 'bar', |
|
| 637 | 'has_value' => '42', |
|
| 638 | ] |
|
| 639 | ], |
|
| 640 | ], |
|
| 641 | ] |
|
| 642 | ], |
|
| 643 | ], |
|
| 644 | ]) |
|
| 645 | ); |
|
| 646 | ||
| 647 | $properties = [ |
|
| 648 | 'bar' => '42', |
|
| 649 | ]; |
|
| 650 | ||
| 651 | Resource::box( |
|
| 652 | $properties, |
|
| 653 | $configurator |
|
| 654 | ); |
|
| 655 | } |
|
| 656 | ||
| 657 | /** |
|
| 658 | * @expectedException Sensorario\Resources\Exceptions\EmailException |
|