vm's avatar
Level 2

after login i get /statuses and the Flash message welcome back but test fails

Couldn't see in current url "/statuses":
Failed asserting that '/login' contains "/statuses".

Scenario Steps:
3. I see in current url "/statuses"
2. I log in 
1. As a  member

my cept file says

$I->logIn(); 
$I->seeInCurrentUrl('/statuses');
$I->see('Welcome back!');

hope you can help

0 likes
2 replies
JeffreyWay's avatar

We can't help, if we don't see the code you used to implement this...

vm's avatar
Level 2

Sorry about that, should have added the code. Let me know if this is not enough to clarify

public function store()
 {

  //fetch the form input
        $formData = Input::only('email', 'password');

        // validate the form

        $this->signInForm->validate($formData);

        // invalid then go back

        if(Auth::attempt([
            'email' => Input::get('email'),
            'password' => Input::get('password'),
            'confirmed' => 1 // make sure the user has been email verified
        ]))
        {/*
            if(Agent::isMobile())
            {


            }
          */

            Flash::message('Welcome back!');


            return Redirect::intended('/statuses');

        }else
        {
            Flash::message('Please make sure you verified your email registration and email and password are filled in accurately');

            return Redirect::back();
        }


 }

codecept file is

<?php 
$I = new FunctionalTester($scenario);
$I->am('member');
$I->wantTo('login to my account');
//$I->amNotMobile();
$I->logIn(); // look in FunctionHelper.php for definition of method

$I->seeInCurrentUrl('/statuses');
$I->see('Welcome back!');
$I->assertTrue(Auth::check());

function helper file

<?php
namespace Codeception\Module;

use Laracasts\TestDummy\Factory as TestDummy;

use Jenssegers\Agent\Facades\Agent;

class FunctionalHelper extends \Codeception\Module
{
        public function logIn()
        {
            $email = 'foo@example.com';
            $password = 'foo';

            $this->haveAnAccount(compact('email', 'password'));

            $I = $this->getModule('Laravel4');


            $I->amOnPage('/login');
            $I->fillField('email',$email );
            $I->fillField('password',$password);

            $I->click('Log In');

        }
        public function haveAnAccount($overrides = [])
        {
          TestDummy::create('MyApp\Users\User', $overrides);
        }

        public function amNotMobile()
        {
           ! Agent::isMobile();

        }
}

I am also not sure how I will test Flash:: message and the Agent is Mobile not commented out

Appreciate your help Thx PS a more indepth tutorial on codeception would be great -- again thx

Please or to participate in this conversation.