I am trying to run phpunit on a development environment. However, whenever I have a function that utilizes the press() function, I get a 404 error.
1) LoginTest::testLoginWithInvalidCredentials
A request to [http://localhost/set/public/auth/login] failed. Received status code [404].
C:\inetpub\wwwroot\set\vendor\laravel\framework\src\Illuminate\Foundation\Testing\InteractsWithPages.php:165
C:\inetpub\wwwroot\set\vendor\laravel\framework\src\Illuminate\Foundation\Testing\InteractsWithPages.php:63
C:\inetpub\wwwroot\set\vendor\laravel\framework\src\Illuminate\Foundation\Testing\InteractsWithPages.php:85
C:\inetpub\wwwroot\set\vendor\laravel\framework\src\Illuminate\Foundation\Testing\InteractsWithPages.php:658
C:\inetpub\wwwroot\set\vendor\laravel\framework\src\Illuminate\Foundation\Testing\InteractsWithPages.php:645
C:\inetpub\wwwroot\set\tests\LoginTest.php:49
Caused by exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in C:\inetpub\wwwroot\set\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php:161
When I access http://localhost/set/public/auth/login, the URL works fine. In fact, when I utilize the site, everything works. Also, if I run the phpunit on my local machine, I don't get the error at all.
I have checked over my .env file and everything checks out for the system to work. And my routes seem correct as well. If I manually run the test, everything performs correctly. It is just running this phpunit test that fails.
Any direction as to where to look would be greatly appreciated.
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class LoginTest extends TestCase
{
use DatabaseTransactions;
public function testLoginPageOk()
{
$this->visit('/')
->see('You are accessing');
}
public function testRedirectToLoginPage()
{
$this->call('GET','/');
$this->assertRedirectedTo('auth/login');
}
public function testAuthLoginRoutes()
{
$this->call('GET', '/auth/login');
$this->see('You are accessing');
}
public function testLoginWithInvalidCredentials()
{
$this->visit('/auth/login')
->type('asdf', 'username')
->type('gibberish', 'password')
->press('Sign in')
->see('These credentials do not match our records.');
}
}
Here is my routes file:
<?php
// This group requires a user to be logged in.
Route::group(['middleware' => 'auth'], function() {
// when you login, if you were not going to a page, you get directed
// to /home. Let's push that to the actual home page.
Route::get('home', function(){ return redirect('/');});
Route::get('/', 'HomeController@index');
});
// Authentication routes. Doesn't need to be logged in.
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
And finally my .env file is as follows:
APP_ENV=local
APP_DEBUG=true
APP_KEY=ycDUbCfgo81OJfc1TjNBjggAtXqwES5I
APP_URL=http://localhost/set/public/
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=ilsausmail
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null