我總是收到錯誤 500,而瀏覽中的狀態為 200。我已經檢查了其他答案,但沒有解決方案。
這是 UserTest 中的代碼
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
class UserTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->assertTrue(true);
//$this->withoutExceptionHandling();
$response = $this->get('/');
$response->assertStatus(200);
}
}
這是測驗的結果
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
F 1 / 1 (100%)
Time: 00:02.105, Memory: 22.00 MB
There was 1 failure:
1) Tests\Feature\UserTest::testExample
Expected status code 200 but received 500.
Failed asserting that false is true.
var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:78
/var/www/laravel/tests/Feature/UserTest.php:22
FAILURES!
Tests: 1, Assertions: 2, Failures: 1.
預先感謝您的回答,即使是很少的線索
uj5u.com熱心網友回復:
這是更正的,我在中間件組件之間存在沖突。謝謝大家
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/367337.html
標籤:laravel-5
