- E-Mail-Aenderung durch Berater wird erst nach Bestaetigung durch den Kunden aktiv (Link an die neue Adresse, Portal kunde/email-bestaetigen); danach ziehen alle Eintraege des Kunden und seine Abos mit. Admins aendern direkt. - Kundenhoheit: E-Mail eines Beraterkontos oder eines Kunden eines anderen Beraters wird abgelehnt (beim Speichern und bei der Bestaetigung). - Fix CustomerPriority::entryExists: aelteste gepruefte Zuordnung gilt, Eintraege in Pruefung (is_like) dienen nicht mehr als Vorlage. - "Berater zuweisen" voreingestellt auf alle Bestellungen des Kunden. - Neue Admin-Seite Kundenhoheit: offene Pruefungen, Kunden bei mehreren Beratern, abgelehnte/offene E-Mail-Aenderungen; Zaehler im Menue. - Neue Tabelle shopping_user_email_changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
2.5 KiB
PHP
77 lines
2.5 KiB
PHP
<?php
|
|
|
|
use App\Models\Country;
|
|
use App\Models\ShoppingUser;
|
|
use App\User;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
beforeEach(function () {
|
|
$this->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('<div class="badge badge-danger">1</div>', 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();
|
|
});
|