Domanda

I'm doing acceptance testing on my site using Codeception. I tried to test login form, but it failed. I tried following directions of my test by hand, and it worked. So, I dived deep into logs of Codeception, and I discovered, that PhpBrowser gets the same url that my browser gets, but without port number.

My test:

<?php
$I = new WebGuy($scenario);
$I->wantTo('visit 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->wantTo('log in without credentials');
$I->click('button[type=submit]');
$I->expectTo('see errors');
$I->see('Pole "Login" jest wymagane');
$I->see('Pole "Hasło" jest wymagane');

$I->wantTo('log in with wrong credentials');
$I->fillField('Login', 'bla');
$I->fillField('Hasło', 'blabla');
$I->click('button[type=submit]');
$I->expectTo('see error');
$I->see('Login lub hasło nieprawidłowe.');

$I->wantTo('log in with correct credentials');
$I->fillField('login', 'admin');
$I->fillField('password', 'admin');
$I->click('button[type=submit]');
$I->expectTo('get redirected to homepage');
$I->canSeeCurrentUrlEquals('/');
$I->expectTo('be logged in');
$I->see('Zalogowano jako Administrator');
$I->see('Wyloguj');

My form:

{{ Form::open(['route' => 'login']) }}
    <fieldset>
        <legend>Logowanie</legend>
        <div class="container">
            <div class="form-group{{ ($errors->has('login')) ? ' has-error' : ''}}">
                {{ Form::label('login', 'Login', ['class' => 'control-label']) }}
                {{ Form::text('login', null, ['class' => 'form-control', 'placeholder' => 'Login']) }}

                @if($errors->has('login'))
                    <span class="help-block">
                        @foreach($errors->get('login') as $error)
                            <p>{{ $error }}</p>
                        @endforeach
                    </span>
                @endif
            </div>
            <div class="form-group{{ ($errors->has('password')) ? ' has-error' : ''}}">
                {{ Form::label('password', 'Hasło', ['class' => 'control-label']) }}
                {{ Form::password('password', ['class' => 'form-control', 'placeholder' => 'Hasło']) }}

                @if($errors->has('password'))
                    <span class="help-block">
                        @foreach($errors->get('password') as $error)
                            <p>{{ $error }}</p>
                        @endforeach
                    </span>
                @endif
            </div>
            <div class="checkbox">
                <label>
                    {{ Form::checkbox('rememberMe') }} Zapamiętaj mnie
                </label>
            </div>
            {{ Form::button('<i class="fa fa-sign-in"></i> Zaloguj', ['class' => 'btn btn-primary', 'type' => 'submit']) }}
        </div>
    </fieldset>
    {{ Form::close() }}

How to fix it?

È stato utile?

Soluzione

It actually wasn't an issue, since Codeception used Laravel4 module, which bypasses URL stuff.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top