rap2hpoutre / fast-excel

🦉 Fast Excel import/export for Laravel
MIT License
2.09k stars 246 forks source link

test: support fake #265

Closed tu6ge closed 2 years ago

tu6ge commented 2 years ago

It is convenient for developer to test their own code. this is very necessary, other project is required you, It can write test case 100% coverage. it can assert download:

ExcelFacades::fake();

$this->app->fastexcel->download('bar.xlsx');

$this->app->fastexcel->assertDownloaded('bar.xlsx');

and with assert data:

ExcelFacades::fake();

$original_collection = $this->collection();

$this->app->fastexcel->data($original_collection)->download('bar.xlsx');

$this->app->fastexcel->assertDownloaded('bar.xlsx', function ($data) use ($original_collection) {
    if ($data->toJson() == $original_collection->toJson()) {
        return true;
    }

    return false;
});