Skip to content
This repository was archived by the owner on Jul 16, 2021. It is now read-only.
This repository was archived by the owner on Jul 16, 2021. It is now read-only.

Add dd method to the testing HTTP chain #2511

Closed
@duncanmcclean

Description

@duncanmcclean

I've been writing some HTTP tests today and I've had an idea. I'm posting here to see if it's something others would be interested in..

Right now, when you're writing HTTP tests in Laravel and you want to dd (to debug the response), you'll have to assign your HTTP test chain to a variable and then do dd($response) or whatever.

$response = $this
  ->actingAs($user)
  ->post('/endpoint', $data);

dd($response);

This can sometimes be a bit annoying and tedious. Especially if you have methods that are added after the ->post(), like assertSee or assertRedirect as you have to comment those lines out, then add the semicolon into the right place. It's a faff (I think so anyway).

$response = $this
  ->actingAs($user)
  ->post('/endpoint', $data);
//  ->assertRedirect('/all-good');

dd($response);

However, to get round this, maybe Laravel could have a ->dd() method on the HTTP testing chain? Similar to the way it works with Collections, where it would die dump the response body for debugging.

$this
  ->actingAs($user)
  ->post('/endpoint', $data)
  ->dd()
  ->assertRedirect('/all-good');

Let me know what you think, if it's something people are interested in, I'm happy to look at PR'ing it into the framework.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions