diff --git a/src/JsonSchema/Constraints/TypeConstraint.php b/src/JsonSchema/Constraints/TypeConstraint.php index b57c6f5e..be8e0672 100644 --- a/src/JsonSchema/Constraints/TypeConstraint.php +++ b/src/JsonSchema/Constraints/TypeConstraint.php @@ -151,7 +151,7 @@ protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = fa */ protected function validateTypeNameWording($type) { - if (!isset(self::$wording[$type])) { + if (!array_key_exists($type, self::$wording)) { throw new StandardUnexpectedValueException( sprintf( 'No wording for %s available, expected wordings are: [%s]', diff --git a/tests/Constraints/TypeTest.php b/tests/Constraints/TypeTest.php index ca6bf7cf..a10996da 100644 --- a/tests/Constraints/TypeTest.php +++ b/tests/Constraints/TypeTest.php @@ -94,7 +94,31 @@ private function assertTypeConstraintError($expected, TypeConstraint $actual) $this->assertSame($expected, $actualMessage); // the same for the strictness } - public function testValidateTypeNameWording() + public function validNameWordingDataProvider() + { + $wordings = array(); + + foreach (array_keys(TypeConstraint::$wording) as $value) { + $wordings[] = array($value); + } + + return $wordings; + } + + /** + * @dataProvider validNameWordingDataProvider + */ + public function testValidateTypeNameWording($nameWording) + { + $t = new TypeConstraint(); + $r = new \ReflectionObject($t); + $m = $r->getMethod('validateTypeNameWording'); + $m->setAccessible(true); + + $m->invoke($t, $nameWording); + } + + public function testInvalidateTypeNameWording() { $t = new TypeConstraint(); $r = new \ReflectionObject($t);