public testMultipleFieldSingleDomain ( ) |
public function testMultipleFieldSingleDomain()
{
$this->specify('Test inclusion in validator with multiple field and single domain.', function () {
$validation = new Validation();
$validationMessages = ['type' => 'Type must be mechanical or cyborg.', 'anotherType' => 'AnotherType must be mechanical or cyborg.'];
$validation->add(['type', 'anotherType'], new InclusionIn(['domain' => ['mechanical', 'cyborg'], 'message' => $validationMessages]));
$messages = $validation->validate(['type' => 'cyborg', 'anotherType' => 'cyborg']);
expect($messages->count())->equals(0);
$messages = $validation->validate(['type' => 'hydraulic', 'anotherType' => 'cyborg']);
expect($messages->count())->equals(1);
expect($messages->offsetGet(0)->getMessage())->equals($validationMessages['type']);
$messages = $validation->validate(['type' => 'hydraulic', 'anotherType' => 'hydraulic']);
expect($messages->count())->equals(2);
expect($messages->offsetGet(0)->getMessage())->equals($validationMessages['type']);
expect($messages->offsetGet(1)->getMessage())->equals($validationMessages['anotherType']);
});
}