Skip to content

Commit 9172c4c

Browse files
committed
Rename stub per mother
1 parent 5439261 commit 9172c4c

File tree

16 files changed

+42
-42
lines changed

16 files changed

+42
-42
lines changed

more-readable-code-avoiding-builder-pattern/3-object_mother/test/Stub/AccessLevelStub.php renamed to more-readable-code-avoiding-builder-pattern/3-object_mother/test/Mother/AccessLevelMother.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Faker\Factory;
66

7-
final class AccessLevelStub
7+
final class AccessLevelMother
88
{
99
public static function create(int $accessLevel)
1010
{

more-readable-code-avoiding-builder-pattern/3-object_mother/test/Stub/UserIdStub.php renamed to more-readable-code-avoiding-builder-pattern/3-object_mother/test/Mother/UserIdMother.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Faker\Factory;
66

7-
final class UserIdStub
7+
final class UserIdMother
88
{
99
public static function create(string $id)
1010
{

more-readable-code-avoiding-builder-pattern/3-object_mother/test/Stub/UserStub.php renamed to more-readable-code-avoiding-builder-pattern/3-object_mother/test/Mother/UserMother.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types = 1);
44

5-
final class UserStub
5+
final class UserMother
66
{
77
public static function create(UserId $id, UserName $name, AccessLevel $accessLevel)
88
{
@@ -11,25 +11,25 @@ public static function create(UserId $id, UserName $name, AccessLevel $accessLev
1111

1212
public static function withId(UserId $id)
1313
{
14-
return self::create($id, UserNameStub::random(), AccessLevelStub::random());
14+
return self::create($id, UserNameMother::random(), AccessLevelMother::random());
1515
}
1616

1717
public static function withValues(string $id, string $name, int $accessLevel)
1818
{
1919
return self::create(
20-
UserIdStub::create($id),
21-
UserNameStub::create($name),
22-
AccessLevelStub::create($accessLevel)
20+
UserIdMother::create($id),
21+
UserNameMother::create($name),
22+
AccessLevelMother::create($accessLevel)
2323
);
2424
}
2525

2626
public static function withAccessLevel(int $accessLevel)
2727
{
28-
return self::create(UserIdStub::random(), UserNameStub::random(), AccessLevelStub::create($accessLevel));
28+
return self::create(UserIdMother::random(), UserNameMother::random(), AccessLevelMother::create($accessLevel));
2929
}
3030

3131
public static function random()
3232
{
33-
return self::create(UserIdStub::random(), UserNameStub::random(), AccessLevelStub::random());
33+
return self::create(UserIdMother::random(), UserNameMother::random(), AccessLevelMother::random());
3434
}
3535
}

more-readable-code-avoiding-builder-pattern/3-object_mother/test/Stub/UserNameStub.php renamed to more-readable-code-avoiding-builder-pattern/3-object_mother/test/Mother/UserNameMother.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Faker\Factory;
66

7-
final class UserNameStub
7+
final class UserNameMother
88
{
99
public static function create(string $name)
1010
{

more-readable-code-avoiding-builder-pattern/3-object_mother/test/object-mother.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
function test_user_is_able_to_edit_video_with_enough_access_level(): void
44
{
5-
$user = UserStub::withAccessLevel(3);
5+
$user = UserMother::withAccessLevel(3);
66

77
assertThat(true, $user->canEditVideos());
88
}
99

1010
function test_user_is_not_able_to_edit_videos_without_enough_access_level(): void
1111
{
12-
$user = UserStub::withAccessLevel(1);
12+
$user = UserMother::withAccessLevel(1);
1313

1414
assertThat(false, $user->canEditVideos());
1515
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import scala.util.Random
22

3-
object IntStub {
3+
object IntMother {
44
def random: Int = Random.nextInt()
55

66
def randomUnsigned(max: Int = Int.MaxValue - 1): Int = randomBetween(min = 0, max = max)
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import scala.util.Random
22

3-
object StringStub {
3+
object StringMother {
44
def random(numChars: Int): String = Random.alphanumeric take numChars mkString ""
55
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object UserAccessLevelMother {
2+
def apply(value: Int = IntMother.random): UserAccessLevel = UserAccessLevel(value)
3+
4+
def random: UserAccessLevel = apply()
5+
}

more-readable-code-avoiding-builder-pattern/4-named_arguments/src/test/scala/UserAccessLevelStub.scala

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import java.util.UUID
2+
3+
object UserIdMother {
4+
def apply(value: String): UserId = UserIdMother(UuidMother(value))
5+
6+
def apply(value: UUID): UserId = UserId(value)
7+
8+
def random: UserId = UserId(UuidMother.random)
9+
}

0 commit comments

Comments
 (0)