@camlynfx What is the HTTP status code of the response? The location header would not be sent with an HTTP status code of 200. You would get it with a 302. So unless you redirect (return redirect(...)) after storing the new thread you won't get that header.
Feb 1, 2018
4
Level 5
How to get location from a response?
In lesson 10 of "Lets build a forum with Laravel" series, Jefferey did this dd($response->headers->get('Location')); to get the location like http://forum.dev/threads/some-channel/5. However, I get 'null' only. I am using Laravel 5.5.32 so I am assuming that key isn't available any more. Is there any other method to achieve the same.
Here's the test method -
/** @test */
function an_authenticated_user_can_create_new_forum_threads()
{
$this->signIn();
$thread = make('App\Thread');
$response = $this->post('/threads', $thread->toArray());
$this->get($response->headers->get('Location'))
->assertSee($thread->title)
->assertSee($thread->body);
}
Level 42
1 like
Please or to participate in this conversation.