Example #1
0
 /**
  * Test the php-int-filter
  * 
  * @return null
  */
 public function testIsSatisfiedBySingleFieldPHPIntFilter()
 {
     $field = 'my-field';
     $raw = array($field => 33);
     $filter = 'php-int-filter';
     $this->assertSame($this->controller, $this->controller->addFilter($field, $filter), 'exposes a fluent interface');
     $this->assertTrue($this->controller->isSatisfiedBy($raw));
     $this->assertFalse($this->controller->isError());
     $this->assertEquals(33, $this->controller->getClean($field));
     $raw = array($field => 'abc');
     $this->assertFalse($this->controller->isSatisfiedBy($raw));
     $this->assertTrue($this->controller->isError());
     $error = $this->controller->getError($field);
     $this->assertInstanceOf('Appfuel\\Validate\\Error', $error);
     /* prove the filters default error message was used */
     $filter = new \Appfuel\Validate\Filter\PHPFilter\IntFilter($filter);
     $this->assertEquals($filter->getDefaultError(), $error->current());
     $expected = array($field => $error);
     $this->assertEquals($expected, $this->controller->getErrors());
 }