Exemple #1
0
 /**
  * validates getErrors works as expected
  *
  * @author Daniel Sherman
  * @test
  * @depends testConstruct
  * @covers ::getErrors
  */
 public function testGetErrors()
 {
     $rules = [0 => new Caller('is_string', 'input is not a string'), 1 => new Caller(function ($email) {
         $regex = ";^[a-z0-9!#\$%&'*+/\\=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+/\\=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\$;i";
         if (preg_match($regex, $email) === 1) {
             return true;
         }
         return false;
     }, 'input is not a valid email address')];
     $msg = 'The wrapper error message';
     $test = new Wrapper($rules, $msg);
     $this->assertEquals([$msg], $test->getErrors());
 }