请问一下运行测试用使用 Excel 导出的时候提示错误怎么办
<?php
namespace Tests\Unit;
use App\Action\LuckDraw;
use App\Exports\UsersExport;
use PHPUnit\Framework\TestCase;
use Maatwebsite\Excel\Facades\Excel;
class ExcelTest extends TestCase
{
/**
* A basic unit test example. * * @return void
*/ public function testExample()
{
Excel::download(new UsersExport, 'users.xlsx');
$this->assertTrue(true);
}}
Excel::download(new UsersExport, 'users.xlsx');
RuntimeException : A facade root has not been set.
运行错误了 不知道怎么解决
docs.laravel-excel.com/3.1/exports...
这个excel导出的包
控制器里面可以使用 我想在 测试用例里面用的话 怎么处理 这是什么原因,有没有大佬知道~~
public function test()
{
return Excel::download(new UsersExport, 'users.xlsx');
}
$userExport = $this->make(App\Exports\UsersExport::class);
使用make生成一个类实例试试,在非控制器里似乎不可以直接new