1、composer.json 添加 tests/TestCase.php
"autoload": {
"classmap": [
"database/seeds",
"database/factories",
"app/Handle",
"tests/TestCase.php" // 添加
],
}
2、新建tests/TestCase.php文件
<?php
namespace Tests;
use App\Console\Kernel;
class TestCase extends \Illuminate\Foundation\Testing\TestCase
{
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://localhost';
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__ . '/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
}