Do not manually call setUp in construct. setUp is ran before each test method. If you need to do some magic just extend the base TestCase and overrule the createApplication method.
Also do not override __construct without calling the parent.
I tried to post this a bit ago but I think the original post got lost in the nether thanks to some pasted smart quotes. If this is a double-post I do apologize.
I'm making a point to work on testing early on with a new project, but having a pretty rough time.
If I run either one of the tests below on their own, it will pass. However, when I attempt to run both tests, I am greeted with:
exception 'ErrorException' with message 'Undefined variable: errors’ in <compiled template path>
The views have some basic validation error rendering using this method: {{$errors->first('email')}}
<?php
class AuthTest extends TestCase {
function __construct()
{
parent::setUp();
}
protected $baseUrl = "http://portal.dev";
public function testUserRegistration()
{
$this->visit('/register')
->type('valid@email.com', 'email')
->press('Register')
->seePageIs('/login')
->see('The supplied email is already in the system. Login?');
}
public function testUserLogin()
{
$this->visit('/login')
->seePageIs('/login')
->type('valid@email.com', 'email')
->type('goodpass', 'password')
->press('Sign-In')
->seePageIs('/dashboard'));
}
}
It would appear something is going haywire with middleware and/or sessions, but I'm quite a bit green when it comes to phpunit, let alone testing Laravel.
Any guidance or clues are appreciated. Thanks!
Do not manually call setUp in construct. setUp is ran before each test method. If you need to do some magic just extend the base TestCase and overrule the createApplication method.
Also do not override __construct without calling the parent.
Please or to participate in this conversation.