From fec14f6c7f98fdfc893ec603bcadc9a20be51fd0 Mon Sep 17 00:00:00 2001 From: Thomas Broquist Date: Fri, 9 Jun 2023 07:54:40 +0200 Subject: [PATCH] Add random suffix to email in user object --- src/PrivateDump/Transformer.php | 2 +- tests/PrivateDump/TransformerTest.php | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/PrivateDump/Transformer.php b/src/PrivateDump/Transformer.php index 1dbc1e6..05b8037 100644 --- a/src/PrivateDump/Transformer.php +++ b/src/PrivateDump/Transformer.php @@ -142,7 +142,7 @@ protected function transformObjectUser() $user->firstName = $this->faker->firstName(); $user->lastName = $this->faker->lastName(); - $user->email = sprintf('%s.%s@example.com', mb_strtolower($user->firstName), mb_strtolower($user->lastName)); + $user->email = sprintf('%s.%s-%u@example.com', mb_strtolower($user->firstName), mb_strtolower($user->lastName), $this->faker->randomNumber(3)); $user->userName = $user->email; $user->fullName = "{$user->firstName} {$user->lastName}"; diff --git a/tests/PrivateDump/TransformerTest.php b/tests/PrivateDump/TransformerTest.php index 9f61d3e..bc69a50 100644 --- a/tests/PrivateDump/TransformerTest.php +++ b/tests/PrivateDump/TransformerTest.php @@ -92,11 +92,10 @@ public function object_works() $user1FirstName = $this->transformer->transform('', '@user(user1).firstName'); $user1LastName = $this->transformer->transform('', '@user(user1).lastName'); - $user2FirstName = $this->transformer->transform('', '@user(user2).firstName'); - $user2LastName = $this->transformer->transform('', '@user(user2).lastName'); + $user2Email = $this->transformer->transform('', '@user(user2).email'); - $this->assertEquals($user1Email, sprintf('%s.%s@example.com', mb_strtolower($user1FirstName), mb_strtolower($user1LastName))); + $this->assertStringStartsWith(sprintf('%s.%s-', mb_strtolower($user1FirstName), mb_strtolower($user1LastName)), $user1Email); - $this->assertNotEquals($user1FirstName, $user2FirstName); + $this->assertNotEquals($user1Email, $user2Email); } }