Checkout: minimize registration data
This commit is contained in:
@@ -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' => [],
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
@@ -20,13 +20,10 @@ class CheckoutRegisterRoleTest extends TestCase
|
||||
|
||||
$payload = [
|
||||
'email' => 'buyer@example.test',
|
||||
'username' => 'buyer',
|
||||
'password' => 'Password!123',
|
||||
'password_confirmation' => 'Password!123',
|
||||
'first_name' => 'Soren',
|
||||
'last_name' => 'Eberhardt',
|
||||
'address' => 'Example Street 1',
|
||||
'phone' => '123456789',
|
||||
'package_id' => $package->id,
|
||||
'terms' => true,
|
||||
'privacy_consent' => true,
|
||||
@@ -41,5 +38,6 @@ class CheckoutRegisterRoleTest extends TestCase
|
||||
|
||||
$this->assertNotNull($user);
|
||||
$this->assertSame('user', $user->role);
|
||||
$this->assertSame('buyer@example.test', $user->username);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,14 +26,11 @@ class FullUserFlowTest extends TestCase
|
||||
$freePackage = Package::factory()->endcustomer()->create(['price' => 0]);
|
||||
|
||||
$registrationData = [
|
||||
'username' => 'flowuser',
|
||||
'email' => 'flow@example.com',
|
||||
'password' => 'Password123!',
|
||||
'password_confirmation' => 'Password123!',
|
||||
'first_name' => 'Max',
|
||||
'last_name' => 'Mustermann',
|
||||
'address' => 'Musterstr. 1',
|
||||
'phone' => '+49123456789',
|
||||
'privacy_consent' => true,
|
||||
'terms' => true,
|
||||
'package_id' => $freePackage->id,
|
||||
@@ -132,14 +129,11 @@ class FullUserFlowTest extends TestCase
|
||||
// Schritt 1: Fehlgeschlagene Registrierung (kein Consent)
|
||||
$response = $this->post('/de/register', [
|
||||
'name' => 'Error User',
|
||||
'username' => 'erroruser',
|
||||
'email' => 'error@example.com',
|
||||
'password' => 'Password123!',
|
||||
'password_confirmation' => 'Password123!',
|
||||
'first_name' => 'Max',
|
||||
'last_name' => 'Mustermann',
|
||||
'address' => 'Musterstr. 1',
|
||||
'phone' => '+49123456789',
|
||||
'privacy_consent' => false,
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user