samedi 31 octobre 2015

Phpunit Laravel Flash Message Error

I have the following test class which I'm trying to test for user registration:

 public function a_user_may_register_for_an_account_but_must_confirm_their_email_address()
{
    $this->visit('register')
         ->type('John Doe', 'name')
         ->type('john.doe@example.com', 'email')
         ->type('password', 'password')
         ->press('Register');

    $this->see('Please confirm your email address')
        ->seeInDatabase('users', ['email' => 'john.doe@example.com', 'verified' => 0 ]);

}

But I'm getting the following error message:

' matches PCRE pattern "/(Please confirm your email address|Please confirm your email address)/i".

My controller method is as follows:

public function postRegister(Request $request, AppMailer $mailer)
{
    $validator = $this->validator($request->all());

    if ($validator->fails()) {
        $this->throwValidationException(
            $request, $validator
        );
    }

    $user = $this->create($request->all());

    $mailer->sendEmailConfirmationTo($user);

    flash()->info('Please confirm your email address');

    return redirect()->back();
}

I have a layout.blade view as follows:

<body>
     @include('layouts.partials.nav')
     @include('flash::message')
     @yield('content')
     @include('layouts.partials.footer')
</body>

My registration.blade view is as follows:

@extends('layout.layout')

@section('content')
   <!-- registration form -->

@endsection

When I register using the the browser the flash message displays fine and all is working. Why is php unit then throwing this error?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire