Skip to content

Commit c67f9fd

Browse files
committed
More double-coercion tests
1 parent 69e9cdd commit c67f9fd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/Constraints/CoerciveTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public function testValidCoerceCases($input, $schema, $errors = array())
7070
$this->assertTrue(gettype($value->nullArray) == 'NULL');
7171
$this->assertTrue(gettype($value->doubleCoercion) == 'array');
7272
$this->assertTrue(gettype($value->doubleCoercion2) == 'integer');
73+
$this->assertTrue(gettype($value->doubleCoercion3) == 'integer');
74+
$this->assertTrue(gettype($value->doubleCoercion4) == 'integer');
7375

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

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

99103
$this->assertTrue(gettype($value->multitype1) == 'boolean');
100104
$this->assertTrue(gettype($value->multitype2) == 'double');
@@ -123,6 +127,8 @@ public function testValidCoerceCases($input, $schema, $errors = array())
123127
$this->assertTrue($value->nullArray === array(null));
124128
$this->assertTrue($value->doubleCoercion === 45);
125129
$this->assertTrue($value->doubleCoercion2 === array('45'));
130+
$this->assertTrue($value->doubleCoercion3 === array('45'));
131+
$this->assertTrue($value->doubleCoercion4 === '45');
126132

127133
$this->assertTrue($validator->isValid(), print_r($validator->getErrors(), true));
128134
}
@@ -195,6 +201,8 @@ public function getValidCoerceTests()
195201
"nullArray":null,
196202
"doubleCoercion":["45"],
197203
"doubleCoercion2":45,
204+
"doubleCoercion3":45,
205+
"doubleCoercion4":45,
198206
"null":null,
199207
"any": "string",
200208
"allOf": "1",
@@ -237,6 +245,8 @@ public function getValidCoerceTests()
237245
"nullArray":{"type":"array"},
238246
"doubleCoercion":{"type":"number"},
239247
"doubleCoercion2":{"type":"array","items":[{"type":"string"}]},
248+
"doubleCoercion3":{"anyOf":[{"type":"array","items":[{"type":"string"}]},{"type":"number"}]},
249+
"doubleCoercion4":{"anyOf":[{"type":"array","items":[{"type":"object"}]},{"type":"string"}]},
240250
"null":{"type":"null"},
241251
"any": {"type":"any"},
242252
"allOf" : {"allOf":[{

0 commit comments

Comments
 (0)