3

I have a large problem with acceptance testing Laravel 4.0 using Codeception.

There are many problems with sessions, such as tests involving flashes not going through and logged in user treated as not logged in.

If I do {{ var_dump(Session::all()) }} in view, which I'm testing (login page), then it goes through, but that's not true when I try to test login persistence (on index page that user gets redirected to after login).

It seems that flashes come through when I do it, but not Cartalyst Sentry sessions. Can you help me with that?

My test case:

<?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

Please help me, I was troubleshooting it for 3 days straight, and I'm fed up with this.

If you need any other info, just tell me, I will provide. This is a strange issue, so I don't really know, what to provide.

Cysioland
  • 1,126
  • 1
  • 9
  • 21
  • I can't make heads or tails of what is going on in this code. Sessions are tricky. One issue with non-persistent sessions is that the session name is screwed up. IE a session name can't have spaces, special characters, etc. so, `session_start('my super awesome session');` is invalid. That's the only thing I can suggest, this code makes my head hurt. – Rottingham Mar 17 '14 at 18:18
  • @Rottingham First, my session works in browser, but not when testing. My session name is like `letters_letters`, so I doubt it's invalid. – Cysioland Mar 17 '14 at 18:19
  • What session driver are you using? – sbuck Aug 05 '14 at 07:03

0 Answers0