mercredi 30 septembre 2015

Unti testing ajax, check returned json [Laravel 5 ]

I want to test my controller, I need to see which json returned:

Here is my controller method:

public function update(UpdateCommentRequest $request)
{
        if(Input::get('task') == 'updateComment')
        {
            if(Comment::find(Input::get('id'))
                    ->update(['text' => $request->get('text')]))
            {
                return json_encode(array('success' => true));
            }
        }

}

Here is my test try:

public function testHome()
    {
        $this->be(User::find(1));
        $response = $this->call('PUT', '/api/project/1/comment/1/comments/1', array(
            'text' => 'testjjjjjjjjjjjjjjjjjjjjjjjjjjjj',
            'projectID' => 1,
            'id' => 246,
            'level' => 0
        ));
        dd($response);

Even if my test pass it will not return any content... What is right way to assert if I get succesful ajax request?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire