previousHttpHost = $_SERVER['HTTP_HOST'] ?? null; Mail::fake(); $_SERVER['HTTP_HOST'] = config('domains.domains.crm.host'); $this->refreshApplication(); $this->artisan('migrate'); }); afterEach(function () { // Host wieder zurücksetzen, sonst booten nachfolgende Tests mit den CRM-Routen. if ($this->previousHttpHost === null) { unset($_SERVER['HTTP_HOST']); } else { $_SERVER['HTTP_HOST'] = $this->previousHttpHost; } }); function cppUser(array $attributes = []): User { return User::forceCreate(array_merge([ 'email' => 'cpp-'.uniqid('', true).'@example.com', 'password' => bcrypt('secret'), 'lang' => 'de', 'active' => 1, 'wizard' => 100, 'payment_account' => now()->addYear(), ], $attributes)); } it('zeigt Admins die Übersicht Kundenhoheit mit allen Reitern und dem Zähler im Menü', function (string $tab, string $text) { $admin = cppUser(['admin' => 2]); $country = Country::first() ?? Country::create([ 'code' => 'DE', 'phone' => '49', 'en' => 'Germany', 'de' => 'Deutschland', 'es' => 'Alemania', 'fr' => 'Allemagne', 'it' => 'Germania', 'ru' => 'Германия', ]); ShoppingUser::create([ 'member_id' => $admin->id, 'number' => 71001, 'is_like' => true, 'billing_firstname' => 'Paula', 'billing_lastname' => 'Prüf', 'billing_email' => 'paula@example.com', 'billing_country_id' => $country->id, 'shipping_country_id' => $country->id, ]); $this->actingAs($admin)->get(route('admin_customer_priority', [$tab])) ->assertOk() ->assertSee('Kundenhoheit') ->assertSee($text) ->assertSee('id="datatables-customer-priority"', false) ->assertSee('
1
', false); })->with([ 'Prüfungen' => ['reviews', 'Prüfen & zuordnen'], 'Konflikte' => ['conflicts', 'älteste Zuordnung'], 'E-Mail' => ['email-changes', 'wartet auf Bestätigung'], ]); it('kennt nur die drei Reiter', function () { $this->actingAs(cppUser(['admin' => 2]))->get(route('admin_customer_priority', ['gibt-es-nicht'])) ->assertNotFound(); }); it('sperrt die Übersicht für Berater ohne Admin-Rechte', function () { $this->actingAs(cppUser())->get(route('admin_customer_priority')) ->assertRedirect(); });