Laravel 6/7测试:尚未设置门面根
我正在尝试为我的Laravel 7应用程序编写一些测试。 但我一直面临着未设置门面根的问题。错误。 其他问题对我都没有帮助Laravel 6/7测试:尚未设置门面根,laravel,phpunit,laravel-7,laravel-testing,Laravel,Phpunit,Laravel 7,Laravel Testing,我正在尝试为我的Laravel 7应用程序编写一些测试。 但我一直面临着未设置门面根的问题。错误。 其他问题对我都没有帮助 <?php namespace Tests\Feature; use Illuminate\Support\Facades\Config; use PHPUnit\Framework\TestCase; class AddressListenerRepositoryTest extends TestCase { public function testC
<?php
namespace Tests\Feature;
use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\TestCase;
class AddressListenerRepositoryTest extends TestCase
{
public function testCreate()
{
Config::set('x', 'address_listeners'); // Cause of "A facade root has not been set" error
}
}
您应该使用使用Test\TestCase代码>而不是PHPUnit\Framework\TestCase
测试需要调用createApplication方法,该方法位于test\TestCase
中,该方法将触发内核,从而使每个对象和类都得到引导。然后您可以使用容器、外观、请求、响应和所有这些东西。您应该使用use Test\TestCase代码>而不是PHPUnit\Framework\TestCase
测试需要调用createApplication方法,该方法位于test\TestCase
中,该方法将触发内核,从而使每个对象和类都得到引导。然后您可以使用容器、外观、请求、响应以及所有这些东西