I don't know much about testing, so forgive me if this is a stupid suggestion, but can't you use Laravel's withSession() method to set the session ID?
class SessionTest extends TestCase
{
/** @test */
public function mocking_session_id()
{
$this->withoutExceptionHandling();
// use factory to create content
// register user, log in, etc.
$response = $this->withSession(['id' => 'session_id_1234'])->post('/session-test');
// eventually assert that content belongs to user
$response->assertOk();
}
}
By the way, here are the Laravel Framework session tests, maybe you can pick up something useful: https://github.com/laravel/framework/blob/0b12ef19623c40e22eff91a4b48cb13b3b415b25/tests/Session/SessionStoreTest.php