| @@ 9-41 (lines=33) @@ | ||
| 6 | ||
| 7 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 8 | ||
| 9 | final class UuidTest extends BaseUnitTestCase |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @test |
|
| 13 | */ |
|
| 14 | public function itShouldReturnUuid(): void |
|
| 15 | { |
|
| 16 | $uuid = $this->faker()->uuid; |
|
| 17 | ||
| 18 | $uuidVO = new Uuid($uuid); |
|
| 19 | ||
| 20 | $this->assertSame($uuid, $uuidVO->value()); |
|
| 21 | } |
|
| 22 | ||
| 23 | public function invalidUuidProvider(): array |
|
| 24 | { |
|
| 25 | return [ |
|
| 26 | [$this->faker()->address], |
|
| 27 | ]; |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @test |
|
| 32 | * |
|
| 33 | * @dataProvider invalidUuidProvider |
|
| 34 | */ |
|
| 35 | public function itShouldThrowsException($data): void |
|
| 36 | { |
|
| 37 | $this->expectException(\Exception::class); |
|
| 38 | ||
| 39 | new Uuid($data); |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||
| @@ 9-40 (lines=32) @@ | ||
| 6 | ||
| 7 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 8 | ||
| 9 | final class Ipv4Test extends BaseUnitTestCase |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @test |
|
| 13 | */ |
|
| 14 | public function itShouldReturnIpv4Address(): void |
|
| 15 | { |
|
| 16 | $ipAddress = $this->faker()->ipv4; |
|
| 17 | ||
| 18 | $ipv4 = new Ipv4($ipAddress); |
|
| 19 | ||
| 20 | $this->assertSame($ipAddress, $ipv4->value()); |
|
| 21 | } |
|
| 22 | ||
| 23 | public function invalidIpv4AddressProvider(): array |
|
| 24 | { |
|
| 25 | return [ |
|
| 26 | [$this->faker()->ipv6] |
|
| 27 | ]; |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @test |
|
| 32 | * @dataProvider invalidIpv4AddressProvider |
|
| 33 | */ |
|
| 34 | public function itShouldThrowsException(string $data): void |
|
| 35 | { |
|
| 36 | $this->expectException(\Exception::class); |
|
| 37 | ||
| 38 | new Ipv4($data); |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||
| @@ 8-40 (lines=33) @@ | ||
| 5 | ||
| 6 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 7 | ||
| 8 | final class Ipv6Test extends BaseUnitTestCase |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @test |
|
| 12 | */ |
|
| 13 | public function itShouldReturnIpv6Address(): void |
|
| 14 | { |
|
| 15 | $ipAddress = $this->faker()->ipv6; |
|
| 16 | ||
| 17 | $ipv6 = new Ipv6($ipAddress); |
|
| 18 | ||
| 19 | $this->assertSame($ipAddress, $ipv6->value()); |
|
| 20 | } |
|
| 21 | ||
| 22 | public function invalidIpv6Provider(): array |
|
| 23 | { |
|
| 24 | return [ |
|
| 25 | [$this->faker()->ipv4], |
|
| 26 | [$this->faker()->localIpv4], |
|
| 27 | ]; |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @test |
|
| 32 | * @dataProvider invalidIpv6Provider |
|
| 33 | */ |
|
| 34 | public function itShouldThrowsException(string $data): void |
|
| 35 | { |
|
| 36 | $this->expectException(\Exception::class); |
|
| 37 | ||
| 38 | new Ipv6($data); |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||
| @@ 9-42 (lines=34) @@ | ||
| 6 | ||
| 7 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 8 | ||
| 9 | final class UrlTest extends BaseUnitTestCase |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @test |
|
| 13 | */ |
|
| 14 | public function itShouldReturnUrl(): void |
|
| 15 | { |
|
| 16 | $url = $this->faker()->url; |
|
| 17 | ||
| 18 | $urlVO = new Url($url); |
|
| 19 | ||
| 20 | $this->assertSame($url, $urlVO->value()); |
|
| 21 | } |
|
| 22 | ||
| 23 | public function invalidUrlProvider(): array |
|
| 24 | { |
|
| 25 | return [ |
|
| 26 | [$this->faker()->email], |
|
| 27 | [$this->faker()->phoneNumber], |
|
| 28 | ]; |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @test |
|
| 33 | * |
|
| 34 | * @dataProvider invalidUrlProvider |
|
| 35 | */ |
|
| 36 | public function itShouldThrowsException(string $data): array |
|
| 37 | { |
|
| 38 | $this->expectException(\Exception::class); |
|
| 39 | ||
| 40 | new Url($data); |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||