public function testValidate() { $controller = new Foo(Request::instance()); $result = $controller->test(); $this->assertTrue($result); }
public function testValidate() { $controller = new Foo(); $data = ['username' => 'username', 'nickname' => 'nickname', 'password' => '123456', 'repassword' => '123456', 'email' => '*****@*****.**', '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之间']]; $result = $controller->validate($data, $validate); $this->assertTrue($result); }