コード例 #1
0
 /**
  * Tests a custom filter Lambda
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @since  2014-09-30
  */
 public function testSanitizeCustomLambdaFalseTrue()
 {
     $this->specify("lambda custom filter does not return true", function () {
         $filter = new PhTFilter();
         $filter->add('md5', function ($value) {
             $filtered = preg_replace('/[^0-9a-f]/', '', $value);
             return strlen($filtered) != 32 ? false : $value;
         });
         $expected = md5('why?');
         $actual = $filter->sanitize($expected, 'md5');
         expect($actual)->equals($expected);
     });
 }
コード例 #2
0
ファイル: FilterBase.php プロジェクト: lisong/cphalcon
 /**
  * Tests integers
  *
  * @author Nikos Dimopoulos <*****@*****.**>
  * @since  2012-11-30
  *
  * @param string    $filter
  * @param mixed     $expected
  * @param mixed     $value
  */
 protected function sanitizer($filter, $expected, $value)
 {
     $fl = new PhTFilter();
     $actual = $fl->sanitize($value, $filter);
     expect($expected)->equals($actual);
 }