Answer the question
In order to leave comments, you need to log in
Why does the test output 404?
The second day I struggle with the problem of tests in Laravel 5.4. Any path gives a 404 error. Didn't google anything.
In general, the task is to write tests for the ApiController controller. How to do it the right way? If possible, with examples, thanks in advance!
Issue background :
Project on latest laravel 5.4 available at localhost:8888/streaming_statistic/public
Test:
<?php
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('/');
$response->assertStatus(200);
}
}
./vendor/bin/phpunit
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.
/Applications/MAMP/htdocs/streaming_statistic/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:56
/Applications/MAMP/htdocs/streaming_statistic/tests/Feature/ApiTest.php:16
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
Route::get('/', function () {
return view('welcome');
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question