Skip to content

Commit

Permalink
Added override test
Browse files Browse the repository at this point in the history
  • Loading branch information
igordrnobrega committed Jun 8, 2017
1 parent e4c7975 commit e04117a
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions tests/InputHandlerTest.php
Expand Up @@ -68,11 +68,6 @@ public function define()
$this->add('date', 'datetime');
$this->add('metadata', 'array');

$this->add('price', 'int', [
'required' => true,
'constraints' => [new Range(0)],
]);

$simple = $this->add('simple', 'array');
$simple->add('title', 'string', ['default' => 'Barfoo']);
$simple->add('size', 'int', ['required' => false, 'default' => 15]);
Expand Down Expand Up @@ -108,7 +103,6 @@ class InputHandlerTest extends \PHPUnit_Framework_TestCase
public function testIsHandlingBasicInput()
{
$input = [
'price' => 'igor',
'title' => 'Foobar',
'size' => 35,
'dimensions' => [11, 22, 33],
Expand Down Expand Up @@ -245,7 +239,6 @@ public function testIsHandlingErrors()
public function testIsHandlingTypeJuggling()
{
$input = [
'price' => 'igor',
'title' => '',
'size' => 0,
'dimensions' => [0, 0, 0],
Expand Down Expand Up @@ -358,7 +351,6 @@ public function testIsHandlingInputWithRecursiveHandler()
'title' => 'Barfoo',
'size' => 20,
'child' => [
'price' => 'igor',
'title' => 'Foobar',
'size' => 35,
'dimensions' => [11, 22, 33],
Expand Down Expand Up @@ -448,4 +440,29 @@ public function testIsHandlingInputWithRecursiveHandler()
$fanC->setBirthday(new \DateTime('2000-01-03'));
$this->assertEquals([$fanA, $fanB, $fanC], $child->fans);
}

public function testOverride()
{
$input = [
'price' => 'igor'
];

$inputHandler = new TestConstraintOverrideType();
$inputHandler->bind($input);
$this->assertFalse($inputHandler->isValid());
}
}

class TestConstraintOverrideType extends InputHandler
{
public function define()
{
$this->add('price', 'int', [
'required' => true,
'constraints' => [new Range(0)]
]);
}
}



0 comments on commit e04117a

Please sign in to comment.