Exemple #1
0
 public function testArrayWithPresentKeyShouldReturnTrue()
 {
     $validator = new Key('bar');
     $obj = array();
     $obj['bar'] = 'foo';
     $this->assertTrue($validator->assert($obj));
     $this->assertTrue($validator->check($obj));
     $this->assertTrue($validator->validate($obj));
 }
Exemple #2
0
 public function test_array_with_present_key_should_return_true()
 {
     $validator = new Key('bar');
     $obj = array();
     $obj['bar'] = 'foo';
     $this->assertTrue($validator->assert($obj));
     $this->assertTrue($validator->check($obj));
     $this->assertTrue($validator->validate($obj));
 }
Exemple #3
0
 public function testShouldHaveTheSameReturnValueForAllValidators()
 {
     $rule = new Key('key', new NotEmpty());
     $input = array('key' => '');
     try {
         $rule->assert($input);
         $this->fail('`assert()` must throws exception');
     } catch (\Exception $e) {
     }
     try {
         $rule->check($input);
         $this->fail('`check()` must throws exception');
     } catch (\Exception $e) {
     }
     $this->assertFalse($rule->validate($input));
 }