public function testValidatorWithFilterGroups()
 {
     $allOfFilter = new AllOfFilter([new ClosureFilter('name', v::intVal()), v::key('key', v::regex('/test.+/i'))]);
     static::assertTrue($allOfFilter->matches(['name' => '1234', 'key' => 'test47382']));
     static::assertFalse($allOfFilter->matches(['name' => 'test', 'key' => 'test47382']));
     static::assertFalse($allOfFilter->matches(['name' => '1234', 'key' => 'test']));
 }
示例#2
0
 public function testMultipleChildrenWithTheSamePropertyMatchesAll()
 {
     $filter = new AllOfFilter([new ClosureFilter('test', function ($actual) {
         return $actual != 'foo';
     }), new ClosureFilter('test', function ($actual) {
         return $actual != 'bar';
     })]);
     static::assertTrue($filter->matches(['test' => 'value']));
     static::assertFalse($filter->matches(['test' => 'foo']));
     static::assertFalse($filter->matches(['test' => 'bar']));
 }