Skip to content

Commit

Permalink
More double-coercion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erayd committed Mar 13, 2017
1 parent 69e9cdd commit c67f9fd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/Constraints/CoerciveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public function testValidCoerceCases($input, $schema, $errors = array())
$this->assertTrue(gettype($value->nullArray) == 'NULL');
$this->assertTrue(gettype($value->doubleCoercion) == 'array');
$this->assertTrue(gettype($value->doubleCoercion2) == 'integer');
$this->assertTrue(gettype($value->doubleCoercion3) == 'integer');
$this->assertTrue(gettype($value->doubleCoercion4) == 'integer');

$validator->validate($value, $schema, $checkMode);

Expand All @@ -95,6 +97,8 @@ public function testValidCoerceCases($input, $schema, $errors = array())
$this->assertTrue(gettype($value->nullArray) == 'array');
$this->assertTrue(gettype($value->doubleCoercion) == 'integer');
$this->assertTrue(gettype($value->doubleCoercion2) == 'array');
$this->assertTrue(gettype($value->doubleCoercion3) == 'array');
$this->assertTrue(gettype($value->doubleCoercion4) == 'string');

$this->assertTrue(gettype($value->multitype1) == 'boolean');
$this->assertTrue(gettype($value->multitype2) == 'double');
Expand Down Expand Up @@ -123,6 +127,8 @@ public function testValidCoerceCases($input, $schema, $errors = array())
$this->assertTrue($value->nullArray === array(null));
$this->assertTrue($value->doubleCoercion === 45);
$this->assertTrue($value->doubleCoercion2 === array('45'));
$this->assertTrue($value->doubleCoercion3 === array('45'));
$this->assertTrue($value->doubleCoercion4 === '45');

$this->assertTrue($validator->isValid(), print_r($validator->getErrors(), true));
}
Expand Down Expand Up @@ -195,6 +201,8 @@ public function getValidCoerceTests()
"nullArray":null,
"doubleCoercion":["45"],
"doubleCoercion2":45,
"doubleCoercion3":45,
"doubleCoercion4":45,
"null":null,
"any": "string",
"allOf": "1",
Expand Down Expand Up @@ -237,6 +245,8 @@ public function getValidCoerceTests()
"nullArray":{"type":"array"},
"doubleCoercion":{"type":"number"},
"doubleCoercion2":{"type":"array","items":[{"type":"string"}]},
"doubleCoercion3":{"anyOf":[{"type":"array","items":[{"type":"string"}]},{"type":"number"}]},
"doubleCoercion4":{"anyOf":[{"type":"array","items":[{"type":"object"}]},{"type":"string"}]},
"null":{"type":"null"},
"any": {"type":"any"},
"allOf" : {"allOf":[{
Expand Down

0 comments on commit c67f9fd

Please sign in to comment.