• 15

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Example PHPUnit Test on Laravel 5.4 fails with 404

I can my project on Laravel 5.4 from link: localhost:8888/streaming_statistic/public

I have a test:


namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class ApiTest extends TestCase
    public function testBasicTest()
        $response = $this->get('/');


I run all tests with command


But result is:

PHPUnit 5.7.13 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 222 ms, Memory: 12.25MB

There was 1 failure:

1) Tests\Feature\ApiTest::testBasicTest
Expected status code 200 but received 404.
Failed asserting that false is true.


Tests: 1, Assertions: 1, Failures: 1.

I can open this page http://localhost:8888/streaming_statistic/public/ I have an route:

Route::get('/', function () {
    return view('welcome');

What i am doing wrong? And what the right way to write tests for controller methods in laravel? May be the HTTP tests it not the best solution for them?

for tests this env variable was wrong...


I changed root web server directory to streaming_statistic/public and env to


After that i got:

OK (1 test, 1 assertion)
  • 16
Reply Report
      • 1
    • You might want to validate if the test is actually passing. It might be that on it's seeing a list of all directories and not really reaching your application.

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions