Invalid private ternary operator (?)
I had the same problem with a risky test when testing in Laravel 5. The problem was that in my navigation (default layout file) I had code similar to the following:
<li{{ Request::is('clients*')?' class="active"':'' }}><a href="/clients">Clients</a></li>
The test did not like this section because the ternary operator ( ? ) Was not closed enough. I replaced it with the following to make it work (brackets around the ternary operator section added):
<li{{ (Request::is('clients*')?' class="active"':'') }}><a href="/clients">Clients</a></li>
I found this by removing some of the blade syntax in parts from the requested view, the expanded layout, and the files that were included. At the time the syntax was removed above, it worked, so an error occurred.
Empty exit / section
The same error occurred when I passed an empty value for the lesson, for example, in the following scenario:
layout.blade.php
<h1>@yield('title')</h1>
page.blade.php
@extends('layout') @section('title','')
Other things to consider
It may be understandable, but just in case you made the same mistake: you should check all involved files.
I performed the following test, which visits the login page, enters the email and password and presses the login button:
Tests /AuthenticationTest.php
<?php class AuthenticationTest extends TestCase { // [...] public function testLoginSuccessful() { $password = str_random(); $user = factory(App\User::class)->create(['password' => $password]); $this->visit(route('login')) ->type($user->email, 'email') ->type($password, 'password') ->press('Login') ->seePageIs(route('dashboard2')); } }
application /Http/routes.php
<?php Route::get('auth/login', 'Auth\AuthController@getLogin')->name('login'); Route::post('auth/login', 'Auth\AuthController@postLogin');
application / Http / Controllers / Auth / AuthController.php
<?php // [...] class AuthController extends Controller { // [...] protected $redirectPath = '/dashboard2'; // <-- check this file as well }
Therefore, I had to especially carefully check the following files, where I made changes:
- application /Http/routes.php
- app / Http / Controllers / Auth / AuthController.php -> getLogin function
- resources /views/auth/login.blade.php (returned to Auth \ AuthContoller @getLogin)
- app / Http / Controllers / Auth / AuthController.php -> postLogin function
- resources / views / dashboard 2.blade.php (returned on successful login)