How to upload and Unit test a CSV file via resource controller
Hi all,
I am rather new to Laravel and i have been tasked with created a upload API and unit testing it.
I would be so grateful if someone could guide me through the steps. needed to get the test's green light :)
I currently have a ListImportController class with a function of store() and a ListImportControllerTest class with a function of testCreate().
Thanks in advance.
Did you write the functionality for the controller already?
There are multi ways of testing this and it depends on what you want to test. For example do you want to test if the file is uploaded at all? This sounds more like a integration test.
For unit testing you can simply this proces and take an example csv file and process that one, but then again I have no idea what you want to achieve with your controller method!
Thanks for your response Bobby,
I want to test if a CSV file has actually been uploaded and deposited in storage.crm.data for the test to asset true.
I have tried and tried again I have no functionality in the controller yet since I am starting from scratch...
I would like to get a test.csv and test that it has been uploaded.