samedi 20 juillet 2019

how to don't remove Trailing slash with laravel test response

I want to know how to test without ignoring Trailing slash.

I test redirect with laravel 5.6. Redirect test url is with Trailing slash and without Trailing slash.

// Feature Test
public function testSample()
{
    // get method ignore trailing slash 
    $response = $this->get("/aaaa/");
    $response->assertRedirect("/bbbb");
}

// middleware method
public function handle($request, Closure $next)
{
    // REQUEST_URI is "/aaaa"
    if(\Request::server('REQUEST_URI') === "/aaaa/"){
        return redirect("/bbbb", "301");
    } elseif(\Request::server('REQUEST_URI') === "/aaaa") {
        return redirect("/cccc", "301");
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire