Permalink
Browse files

Fixed key validator error on non-array input.

  • Loading branch information...
alganet committed Apr 28, 2011
1 parent 5d7a9e1 commit 1ae18f2f5abb929bd2c7bc5c569f678b98b4a99e
@@ -24,7 +24,7 @@ public function getReferenceValue($input)
public function hasReference($input)
{
return array_key_exists($this->reference, $input);
return is_array($input) && array_key_exists($this->reference, $input);
}
}
@@ -48,6 +48,7 @@ public function providerForNotArray()
array(121),
array(new \stdClass),
array(false),
array('aaa'),
);
}
@@ -23,6 +23,15 @@ public function testNotNull()
$obj['baraaaaaa'] = 'foo';
$this->assertTrue($validator->assert($obj));
}
/**
* @expectedException Respect\Validation\Exceptions\KeyException
*/
public function testNotArray()
{
$validator = new Key('bar');
$obj = 123;
$this->assertFalse($validator->assert($obj));
}
/**
* @expectedException Respect\Validation\Exceptions\ComponentException

0 comments on commit 1ae18f2

Please sign in to comment.