JillzTom's avatar

Testing Ajax File upload in phpunit

I'm trying to test an ajax file upload.


    /** @test */
    public function it_uploads_a_user_dp(){

        $this->be(\App\User::where('username', 'ringo')->first());
        $this->withoutMiddleware();
        $this->attach('C:\Users\User\Downloads\858696_10200257365370424_481867196_o.jpg', 'custom_dp')
             ->post('/account/upload_dp')
             ->seeJson(["success"=>true]);
    }

I tried this, but it's not passing the condition if (Input::hasFile('custom_dp')) in my controller and return "success"->false

How can I test this?

0 likes
1 reply

Please or to participate in this conversation.