Hi, Did you find a solution to this problem>
Dec 12, 2016
3
Level 2
File Upload With Behat
I am trying to test a simple upload with Behat. When i test manually in browser, the code works fine. But when I run my test, I have this error :
The image failed to upload
In searching, I founded that method isValid() from UploadedFile return false because of test attribute is false and is_uploaded_file method return false too.
How to solve this ?
Here is my feature :
Feature: Add an advert
In order to advert is public visible
As a user connected
I want to add an advert
Scenario: Add a simple advert
Given I am on "/adverts/create"
Then I should see "Add an advert"
When I fill in "name" with "House"
And I attach the file "IMG_0119.jpg" to "image"
And I fill in "description" with "Description"
And I press "Submit"
Then I should see "Advert added."
Here is my controller method :
public function store(Request $request)
{
$validator = $this->validate($request, [
'image' => 'required|image',
]);
return redirect('/adverts/create')->with('success', trans('advert.created.success'));
Please or to participate in this conversation.