public function testValidateRunsAllValidators() { $dataValidator = new DataValidator(); $dataValidator->addValidator(function (array $data) { return 'always_fail_one'; }); $dataValidator->addValidator(function (array $data) { return 'always_fail_two'; }); assertThat('`validate` should run the data against each registered validator.', $dataValidator->validate([1, 2, 3]), is(anArray(['always_fail_one' => true, 'always_fail_two' => true]))); }
public function testProcessAppliesAllProcessors() { $dataValidator = new DataValidator(); $dataValidator->addProcessor(function (array $data) { $data['one'] = 1; return $data; }); $dataValidator->addProcessor(function (array $data) { $data['two'] = 2; return $data; }); assertThat('`process` should apply all registered processors to the given data array.', $dataValidator->process([]), is(anArray(['one' => 1, 'two' => 2]))); }