我想编写需要验证的WebTestCase视图。可能吗?我怎样才能通过身份验证?
我尝试在会话中编写基本的身份验证,但它不起作用。
$_SESSION['Auth']['User']['id'] = 1;
$_SESSION['Auth']['User']['username'] = 'nico';
答案 0 :(得分:0)
function login() {
$this->get($this->host_name."/users/login/");
$this->assertText("Login");
$this->setField("data[User][username]",'xxxx');
$this->setField("data[User][password]",'xxxx');
$this->assertClickable("login");
$this->clickSubmit("login");
$this->assertNoText("Error:");
}