mercredi 11 septembre 2019

Feature tests redirects to /ace?

I am doing my first feature test in my application.

This is the test:

public function testIfStartPageIsLoading()
{
  $response = $this->get('/');
  $response->assertStatus(200);
}

Unfortunately, its not working.

Expected status code 200 but received 302.

Failed asserting that false is true.

This is the $response when I dump it:

Illuminate\Foundation\Testing\TestResponse^ {#828
  +baseResponse: Illuminate\Http\RedirectResponse^ {#641
    #request: null
    #session: null
    #targetUrl: "http://m-nlp.test/ace"
    +headers: Symfony\Component\HttpFoundation\ResponseHeaderBag^ {#642
      #computedCacheControl: array:2 [
        "no-cache" => true
        "private" => true
      ]
      #cookies: array:1 [
        "" => array:1 [
          "/" => array:1 [
            "XSRF-TOKEN" => Symfony\Component\HttpFoundation\Cookie^ {#656
              #name: "XSRF-TOKEN"
              #value: "eyJpdiI6Im0ySlpcLzNWNVYzMXNqZjY4UG1hTlhRPT0iLCJ2YWx1ZSI6IndWSGJBY3FmbFozK0xhaldoK3ZlUmxFVEswZFdyQmFOa04wKzhTdlA5TWdvRDJUWWc1clBCZjhnQTVnbk5uMnQiLCJtYWMiOiIyOGQ1ODFhY2E0NWZjYzY2YjdlNmQyNDU3OTU3ZWM0NGQ5MjNhMmZmNjA1OTU4M2FmYmYxMGVlYzhmM2MyMDM4In0="
              #domain: null
              #expire: 1568265636
              #path: "/"
              #secure: false
              #httpOnly: false
              -raw: false
              -sameSite: null
              -secureDefault: false
            }
          ]
        ]
      ]
      #headerNames: array:6 [
        "vary" => "Vary"
        "cache-control" => "Cache-Control"
        "date" => "Date"
        "location" => "Location"
        "set-cookie" => "Set-Cookie"
        "content-type" => "Content-Type"
      ]
      #headers: array:5 [
        "vary" => array:1 [
          0 => "Accept-Language"
        ]
        "cache-control" => array:1 [
          0 => "no-cache, private"
        ]
        "date" => array:1 [
          0 => "Wed, 11 Sep 2019 17:20:36 GMT"
        ]
        "location" => array:1 [
          0 => "http://m-nlp.test/ace"
        ]
        "content-type" => array:1 [
          0 => "text/html; charset=UTF-8"
        ]
      ]
      #cacheControl: []
    }
    #content: """
      <!DOCTYPE html>\n
      <html>\n
          <head>\n
              <meta charset="UTF-8" />\n
              <meta http-equiv="refresh" content="0;url=http://m-nlp.test/ace" />\n
      \n
              <title>Redirecting to http://m-nlp.test/ace</title>\n
          </head>\n
          <body>\n
              Redirecting to <a href="http://m-nlp.test/ace">http://m-nlp.test/ace</a>.\n
          </body>\n
      </html>
      """
    #version: "1.1"
    #statusCode: 302
    #statusText: "Found"
    #charset: null
    +original: null
    +exception: null
  }
}

As far as I understand it, it seems like he wants to redirect me to http://m-nlp.test/ace. However, if I go in my browser to http://m-nlp.test then I won't get redirected and everything seems to work.

What is the issue here?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ZRlq9A
via IFTTT

Aucun commentaire:

Enregistrer un commentaire