Вопрос

I want to test that my /login page is working well and rejecting invalid credentials i.e. not redirecting to the user's dashboard and showing an aller message identified here with the .alert HTML class. So I've created a test like this:

class AuthControllerTest extends Zend_Test_PHPUnit_ControllerTestCase {
    ...
    public function testUserFailingLogin() {

        $this->request->setPost(array(
            'email'  => 'wrong@email.com',
            'password' => 'wrongpassword',
        ));

        $this->request->setMethod('POST');
        $this->dispatch('/login');

        $this->assertQuery('.alert');
    }
}

My problem is that the assertQuery() method is running against the render of login.phtml view file and is not including my Zend_Layout set up (that's where the .alert's are shown) and thereof, the assertQuery() assertion fails always.

Is there any way to get assert*Query*() assertions evaluating the full response ("layout" + "view"), instead of just the "view" part?

Это было полезно?

Решение

You(I) should use the undocumented outputBody() method.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top