3

我在使用 Codeception 对 Laravel 4.0 进行验收测试时遇到了一个大问题。

会话存在许多问题,例如涉及闪烁的测试未通过以及已登录的用户被视为未登录。

如果我{{ var_dump(Session::all()) }}在视图中进行测试(登录页面),那么它会通过,但是当我尝试测试登录持久性时(在登录后用户被重定向到的索引页面上),情况并非如此。

我这样做时似乎会出现闪光,但不会出现 Cartalyst Sentry 会话。你能帮我解决这个问题吗?

我的测试用例:

<?php
$I = new WebGuy($scenario);
$I->wantToTest('login page');
$I->amOnPage('/panel/login');

$I->expectTo('see title of form');
$I->see('Logowanie');

$I->expectTo('see form fields');
$I->seeElement('input[type=text]');
$I->seeElement('input[type=password]');

$I->amGoingTo('log in without credentials');
$I->click('Zaloguj');
$I->expectTo('see errors');
$I->seeInCurrentUrl('/panel/login');
$I->see('Pole "Login" jest wymagane.'); // this and bottom one are flashes that don't go through if I don't include that weird snippet
$I->see('Pole "Hasło" jest wymagane.');

$I->amGoingTo('log in with wrong credentials');
$I->fillField('Login', 'bla');
$I->fillField('Hasło', 'blabla');
$I->click('Zaloguj');
$I->expectTo('see error');
$I->seeInCurrentUrl('/panel/login');
$I->see('Login lub hasło nieprawidłowe.');

$I->amGoingTo('log in with correct credentials');
$I->fillField('Login', 'admin');
$I->fillField('Hasło', 'admin');
$I->click('Zaloguj');
$I->expectTo('get redirected to homepage');
$I->canSeeCurrentUrlEquals('/');
$I->expectTo('be logged in');
$I->see('Witaj, Administrator');
$I->see('Wyloguj'); // this button is visible when user is logged in

请帮助我,我连续 3 天对其进行故障排除,我对此感到厌烦。

如果您需要任何其他信息,请告诉我,我会提供。这是一个奇怪的问题,所以我真的不知道该提供什么。

4

0 回答 0