/** * Tests invalid input data. */ public function testInvalid() { $input = new Fluent(); $input->check('foo', 'foo')->validate('isInt', 'not int'); $this->assertFalse($input->isValid()); $this->assertEquals(array('not int'), $input->getErrors()); $input = new Fluent(); $input->check('bar', 'bar')->validate('isInt', 'not int'); $this->assertFalse($input->isValid(true)); $this->assertEquals(array('bar' => array('not int')), $input->getErrors()); $input = new Fluent(); $input->check('foo', 'foo')->all()->validate('isInt'); $this->assertFalse($input->isValid()); $this->setExpectedException('\\Jyxo\\Input\\Exception'); $input->getValue('bar'); }
/** * Tests invalid input data. */ public function testInvalid() { $input = new Fluent(); $input->check('foo', 'foo')->validate('isInt', 'not int'); $this->assertFalse($input->isValid()); $this->assertEquals(['not int'], $input->getErrors()); $input = new Fluent(); $input->check('bar', 'bar')->validate('isInt', 'not int'); $this->assertFalse($input->isValid(true)); $this->assertEquals(['bar' => ['not int']], $input->getErrors()); $input = new Fluent(); $input->check('foo', 'foo')->all()->validate('isInt'); $this->assertFalse($input->isValid()); $this->expectException(\Jyxo\Input\Exception::class); $input->getValue('bar'); }