tests\thinkphp\library\think\Foo::test PHP Method

test() public method

public test ( )
    public function test()
    {
        $data = ['username' => 'username', 'nickname' => 'nickname', 'password' => '123456', 'repassword' => '123456', 'email' => '[email protected]', 'sex' => '0', 'age' => '20', 'code' => '1234'];
        $validate = [['username', 'length:5,15', '用户名长度为5到15个字符'], ['nickname', 'require', '请填昵称'], ['password', '[\\w-]{6,15}', '密码长度为6到15个字符'], ['repassword', 'confirm:password', '两次密码不一到致'], ['email', 'filter:validate_email', '邮箱格式错误'], ['sex', 'in:0,1', '性别只能为为男或女'], ['age', 'between:1,80', '年龄只能在10-80之间']];
        return $this->validate($data, $validate);
    }

Usage Example

Example #1
0
 public function testValidate()
 {
     $controller = new Foo(Request::instance());
     $result = $controller->test();
     $this->assertTrue($result);
 }