Checkout: minimize registration data
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-06 09:23:01 +01:00
parent 29c3c42134
commit 33af04db1b
9 changed files with 105 additions and 157 deletions

View File

@@ -15,14 +15,11 @@ class CheckoutAuthTest extends TestCase
private function registrationPayload(Package $package, array $overrides = []): array
{
return array_merge([
'username' => 'testuser',
'email' => 'test@example.com',
'password' => 'password123',
'password_confirmation' => 'password123',
'first_name' => 'Test',
'last_name' => 'User',
'address' => 'Test Address 123',
'phone' => '+49123456789',
'terms' => true,
'privacy_consent' => true,
'package_id' => $package->id,
@@ -169,7 +166,7 @@ class CheckoutAuthTest extends TestCase
]);
$this->assertDatabaseHas('users', [
'username' => 'testuser',
'username' => 'test@example.com',
'email' => 'test@example.com',
'first_name' => 'Test',
'last_name' => 'User',
@@ -202,7 +199,7 @@ class CheckoutAuthTest extends TestCase
]);
$this->assertDatabaseHas('users', [
'username' => 'testuser',
'username' => 'test@example.com',
'email' => 'test@example.com',
'pending_purchase' => true,
]);
@@ -215,14 +212,11 @@ class CheckoutAuthTest extends TestCase
$package = Package::factory()->create();
$response = $this->postJson(route('checkout.register'), $this->registrationPayload($package, [
'username' => '',
'email' => 'invalid-email',
'password' => '123',
'password_confirmation' => '456',
'first_name' => '',
'last_name' => '',
'address' => '',
'phone' => '',
'terms' => false,
'privacy_consent' => false,
]));
@@ -230,13 +224,10 @@ class CheckoutAuthTest extends TestCase
$response->assertStatus(422)
->assertJsonStructure([
'errors' => [
'username' => [],
'email' => [],
'password' => [],
'first_name' => [],
'last_name' => [],
'address' => [],
'phone' => [],
'terms' => [],
'privacy_consent' => [],
],
@@ -256,14 +247,12 @@ class CheckoutAuthTest extends TestCase
$package = Package::factory()->create();
$response = $this->postJson(route('checkout.register'), $this->registrationPayload($package, [
'username' => 'existinguser',
'email' => 'existing@example.com',
]));
$response->assertStatus(422)
->assertJsonStructure([
'errors' => [
'username' => [],
'email' => [],
],
]);
@@ -274,14 +263,11 @@ class CheckoutAuthTest extends TestCase
public function test_checkout_register_without_package()
{
$response = $this->postJson(route('checkout.register'), [
'username' => 'testuser',
'email' => 'test@example.com',
'password' => 'password123',
'password_confirmation' => 'password123',
'first_name' => 'Test',
'last_name' => 'User',
'address' => 'Test Address 123',
'phone' => '+49123456789',
'terms' => true,
'privacy_consent' => true,
'locale' => 'de',
@@ -368,13 +354,10 @@ class CheckoutAuthTest extends TestCase
$response->assertStatus(422)
->assertJsonStructure([
'errors' => [
'username' => [],
'email' => [],
'password' => [],
'first_name' => [],
'last_name' => [],
'address' => [],
'phone' => [],
'package_id' => [],
'terms' => [],
'privacy_consent' => [],
@@ -457,18 +440,23 @@ class CheckoutAuthTest extends TestCase
$this->assertGuest();
}
public function test_checkout_register_username_too_long()
public function test_checkout_register_email_conflicts_with_existing_username()
{
User::factory()->create([
'username' => 'taken@example.com',
'email' => 'other@example.com',
]);
$package = Package::factory()->create();
$response = $this->postJson(route('checkout.register'), $this->registrationPayload($package, [
'username' => str_repeat('a', 256),
'email' => 'taken@example.com',
]));
$response->assertStatus(422)
->assertJsonStructure([
'errors' => [
'username' => [],
'email' => [],
],
]);