grabRecord(Admin::class, ['email' => 'admin@example.com']); } if (! $admin) { throw new \Exception( 'Admin user not found in database. Please ensure Seeders are executed'); } Auth::guard('admin') ->login($admin); $I->seeAuthentication('admin'); return $admin; } /** * Set the logged in user to the customer identity. * * @param \Webkul\User\Models\Customer|null $customer * * @throws \Exception * @returns Customer */ public function loginAsCustomer(Customer $customer = null): Customer { $I = $this; if (! $customer) { $customer = $I->have(Customer::class); } Auth::guard('customer') ->login($customer); $I->seeAuthentication('customer'); return $customer; } /** * @param string $name */ public function amOnAdminRoute(string $name) { $I = $this; $I->amOnRoute($name); $I->seeCurrentRouteIs($name); /** @var RouteCollection $routes */ $routes = Route::getRoutes(); $middlewares = $routes->getByName($name)->middleware(); $I->assertContains('admin', $middlewares, 'check that admin middleware is applied'); } }