Skip to content

Commit

Permalink
Merge pull request #19 from carandclassic/fixup/improve-email-uniqueness
Browse files Browse the repository at this point in the history
Add random suffix to email in user object
  • Loading branch information
thomas-brx authored Jun 9, 2023
2 parents 47c7f33 + fec14f6 commit cf4d6a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/PrivateDump/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function transformObjectUser()

$user->firstName = $this->faker->firstName();
$user->lastName = $this->faker->lastName();
$user->email = sprintf('%s.%[email protected]', 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}";

Expand Down
7 changes: 3 additions & 4 deletions tests/PrivateDump/TransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit cf4d6a2

Please sign in to comment.