rati_geo's avatar

how to write Feature Test for -excel document uploading

i'm using https://docs.laravel-excel.com/ for uploading Excel and then display on view

how to write test for checking this process ?

here is my controller:

   public function import() 
{
    $rows= Excel::toArray(new ProfitAndLosImport, request()->file('pl'));
    return view("pl")->with(compact('rows'));
}

i'm using this but it's working

   public function testUpload()
    {
        Excel::fake();
        $this->actingAs(factory('App\User')->create());
        $testFile = UploadedFile::fake()->create('borrowers.xlsx');
        $response =$this->post('pl',['pl'=>$testFile]);
       Excel::assertImported('create_terms.xls', function(ProfitAndLosImport $import) {
        return true;
        });
    }

Any help would be much appreciated

0 likes
0 replies

Please or to participate in this conversation.