DB::table('team')->truncate(); $this->get('public_api/teams')->seeJson(['data' => []]); $res = $this->get('public_api/teams?game_id=3')->decodeResponseJson(); $this->assertEquals(1, count($res['data'])); $res = $this->get('public_api/teams?game_id=3')->decodeResponseJson(); $this->assertEquals(1, count($res['data'])); 

For example, an unregistered user visits the site and a command is immediately created for him. The session id is recorded in the command table. if it comes again, the command is selected by session id. The point of the test is to check if a command is being created every time the user logs in. But in the test every time a new session id, unlike the browser. How to make the same session id in one test method or can it be set in a test?

As far as I understand each test in the tests is as if the user opens a browser, and accordingly a new session is created.

  • $this->withSession() - does not suit you? just see that the session settings were set in the default phpunit file in my opinion Array - Orange_shadow
  • and how to use it? - Jonny Manowar
  • Read in the documentation - Orange_shadow
  • This way doesn't work - Jonny Manowar

0