user = $this->createAdminUser(); $this->actingAs($this->user); } /** Return the root administrator the test is currently acting as. */ public function getAdminUser(): User { return $this->user; } /** Create a root administrator user. */ protected function createAdminUser(): User { return User::factory()->create([ 'root_admin' => true, ]); } /** Switch to a non-administrative account to assert the admin API rejects it. */ protected function actingAsNonAdmin(): User { $user = User::factory()->create([ 'root_admin' => false, ]); $this->actingAs($user); return $user; } }