| @@ 8-44 (lines=37) @@ | ||
| 5 | use PhpValueObjects\Geography\Exception\InvalidLanguageCodeException; |
|
| 6 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 7 | ||
| 8 | class LanguageCodeValueObjectTest extends BaseUnitTestCase |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @test |
|
| 12 | */ |
|
| 13 | public function itShouldReturnLanguageCode() |
|
| 14 | { |
|
| 15 | $language = $this->faker()->languageCode; |
|
| 16 | ||
| 17 | $langVO = new LanguageCodeValueObject($language); |
|
| 18 | ||
| 19 | $this->assertSame($language, $langVO->value()); |
|
| 20 | $this->assertSame($language, $langVO->__toString()); |
|
| 21 | } |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @return array |
|
| 25 | */ |
|
| 26 | public function invalidLanguageCodeProvider() |
|
| 27 | { |
|
| 28 | return [ |
|
| 29 | [null], |
|
| 30 | [$this->faker()->address], |
|
| 31 | [$this->faker()->numberBetween()], |
|
| 32 | ]; |
|
| 33 | } |
|
| 34 | /** |
|
| 35 | * @test |
|
| 36 | * @dataProvider invalidLanguageCodeProvider |
|
| 37 | */ |
|
| 38 | public function isShouldThrowsException($data) |
|
| 39 | { |
|
| 40 | $this->expectException(InvalidLanguageCodeException::class); |
|
| 41 | ||
| 42 | new LanguageCodeValueObject($data); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| @@ 10-48 (lines=39) @@ | ||
| 7 | use PhpValueObjects\Identity\Exception\InvalidEmailException; |
|
| 8 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 9 | ||
| 10 | class EmailValueObjectTest extends BaseUnitTestCase |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @test |
|
| 14 | */ |
|
| 15 | public function itShouldReturnEmail() |
|
| 16 | { |
|
| 17 | $email = $this->faker()->email; |
|
| 18 | ||
| 19 | $emailVO = new EmailValueObject($email); |
|
| 20 | ||
| 21 | $this->assertSame($email, $emailVO->value()); |
|
| 22 | $this->assertSame($email, $emailVO->__toString()); |
|
| 23 | } |
|
| 24 | ||
| 25 | /** |
|
| 26 | * @return array |
|
| 27 | */ |
|
| 28 | public function invalidEmailProvider() |
|
| 29 | { |
|
| 30 | return [ |
|
| 31 | [null], |
|
| 32 | [$this->faker()->numberBetween()], |
|
| 33 | [$this->faker()->address], |
|
| 34 | ]; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * @test |
|
| 39 | * |
|
| 40 | * @dataProvider invalidEmailProvider |
|
| 41 | */ |
|
| 42 | public function itShouldThrowsException($data) |
|
| 43 | { |
|
| 44 | $this->expectException(InvalidEmailException::class); |
|
| 45 | ||
| 46 | new EmailValueObject($data); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| @@ 8-43 (lines=36) @@ | ||
| 5 | use PhpValueObjects\Identity\Exception\InvalidUuidException; |
|
| 6 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 7 | ||
| 8 | class UuidValueObjectTest extends BaseUnitTestCase |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @test |
|
| 12 | */ |
|
| 13 | public function itShouldReturnUuid() |
|
| 14 | { |
|
| 15 | $uuid = $this->faker()->uuid; |
|
| 16 | ||
| 17 | $uuidVO = new UuidValueObject($uuid); |
|
| 18 | ||
| 19 | $this->assertSame($uuid, $uuidVO->value()); |
|
| 20 | $this->assertSame($uuid, $uuidVO->__toString()); |
|
| 21 | } |
|
| 22 | ||
| 23 | public function invalidUuidProvider() |
|
| 24 | { |
|
| 25 | return [ |
|
| 26 | [null], |
|
| 27 | [$this->faker()->numberBetween()], |
|
| 28 | [$this->faker()->address], |
|
| 29 | ]; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @test |
|
| 34 | * |
|
| 35 | * @dataProvider invalidUuidProvider |
|
| 36 | */ |
|
| 37 | public function itShouldThrowsException($data) |
|
| 38 | { |
|
| 39 | $this->expectException(InvalidUuidException::class); |
|
| 40 | ||
| 41 | new UuidValueObject($data); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 8-46 (lines=39) @@ | ||
| 5 | use PhpValueObjects\Network\Exception\InvalidIpv4Exception; |
|
| 6 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 7 | ||
| 8 | class Ipv4ValueObjectTest extends BaseUnitTestCase |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @test |
|
| 12 | */ |
|
| 13 | public function itShouldReturnIpv4Address() |
|
| 14 | { |
|
| 15 | ||
| 16 | $ipAddress = $this->faker()->ipv4; |
|
| 17 | ||
| 18 | $ipv4 = new Ipv4ValueObject($ipAddress); |
|
| 19 | ||
| 20 | $this->assertSame($ipAddress, $ipv4->value()); |
|
| 21 | $this->assertSame($ipAddress, $ipv4->__toString()); |
|
| 22 | } |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @return array |
|
| 26 | */ |
|
| 27 | public function invalidIpv4AddressProvider() |
|
| 28 | { |
|
| 29 | return [ |
|
| 30 | [null], |
|
| 31 | [$this->faker()->numberBetween()], |
|
| 32 | [$this->faker()->ipv6] |
|
| 33 | ]; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @test |
|
| 38 | * @dataProvider invalidIpv4AddressProvider |
|
| 39 | */ |
|
| 40 | public function itShouldThrowsException($data) |
|
| 41 | { |
|
| 42 | $this->expectException(InvalidIpv4Exception::class); |
|
| 43 | ||
| 44 | new Ipv4ValueObject($data); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 8-46 (lines=39) @@ | ||
| 5 | use PhpValueObjects\Network\Exception\InvalidIpv6Exception; |
|
| 6 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 7 | ||
| 8 | class Ipv6ValueObjectTest extends BaseUnitTestCase |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @test |
|
| 12 | */ |
|
| 13 | public function itShouldReturnIpv6Address() |
|
| 14 | { |
|
| 15 | $ipAddress = $this->faker()->ipv6; |
|
| 16 | ||
| 17 | $ipv6 = new Ipv6ValueObject($ipAddress); |
|
| 18 | ||
| 19 | $this->assertSame($ipAddress, $ipv6->value()); |
|
| 20 | $this->assertSame($ipAddress, $ipv6->__toString()); |
|
| 21 | } |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @return array |
|
| 25 | */ |
|
| 26 | public function invalidIpv6Provider() |
|
| 27 | { |
|
| 28 | return [ |
|
| 29 | [null], |
|
| 30 | [$this->faker()->ipv4], |
|
| 31 | [$this->faker()->localIpv4], |
|
| 32 | [$this->faker()->numberBetween()], |
|
| 33 | ]; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @test |
|
| 38 | * @dataProvider invalidIpv6Provider |
|
| 39 | */ |
|
| 40 | public function itShouldThrowsException($data) |
|
| 41 | { |
|
| 42 | $this->expectException(InvalidIpv6Exception::class); |
|
| 43 | ||
| 44 | new Ipv6ValueObject($data); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 8-46 (lines=39) @@ | ||
| 5 | use PhpValueObjects\Network\Exception\InvalidUrlException; |
|
| 6 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 7 | ||
| 8 | class UrlValueObjectTest extends BaseUnitTestCase |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @test |
|
| 12 | */ |
|
| 13 | public function itShouldReturnUrl() |
|
| 14 | { |
|
| 15 | $url = $this->faker()->url; |
|
| 16 | ||
| 17 | $urlVO = new UrlValueObject($url); |
|
| 18 | ||
| 19 | $this->assertSame($url, $urlVO->value()); |
|
| 20 | $this->assertSame($url, $urlVO->__toString()); |
|
| 21 | } |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @return array |
|
| 25 | */ |
|
| 26 | public function invalidUrlProvider() |
|
| 27 | { |
|
| 28 | return [ |
|
| 29 | [null], |
|
| 30 | [$this->faker()->email], |
|
| 31 | [$this->faker()->phoneNumber], |
|
| 32 | ]; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @test |
|
| 37 | * |
|
| 38 | * @dataProvider invalidUrlProvider |
|
| 39 | */ |
|
| 40 | public function itShouldThrowsException($data) |
|
| 41 | { |
|
| 42 | $this->expectException(InvalidUrlException::class); |
|
| 43 | ||
| 44 | new UrlValueObject($data); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 8-46 (lines=39) @@ | ||
| 5 | use PhpValueObjects\Identity\Exception\InvalidMd5Exception; |
|
| 6 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 7 | ||
| 8 | class Md5ValueObjectTest extends BaseUnitTestCase |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @test |
|
| 12 | */ |
|
| 13 | public function itShouldReturnMd5Hash() |
|
| 14 | { |
|
| 15 | $md5Hash = $this->faker()->md5; |
|
| 16 | ||
| 17 | $md5VO = new Md5ValueObject($md5Hash); |
|
| 18 | ||
| 19 | $this->assertSame($md5Hash, $md5VO->value()); |
|
| 20 | $this->assertSame($md5Hash, $md5VO->__toString()); |
|
| 21 | } |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @return array |
|
| 25 | */ |
|
| 26 | public function invalidMd5HashProvider() |
|
| 27 | { |
|
| 28 | return [ |
|
| 29 | [$this->faker()->sha1], |
|
| 30 | [$this->faker()->sha256], |
|
| 31 | [$this->faker()->text], |
|
| 32 | ]; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @test |
|
| 37 | * |
|
| 38 | * @dataProvider invalidMd5HashProvider |
|
| 39 | */ |
|
| 40 | public function itShouldThrowsException($data) |
|
| 41 | { |
|
| 42 | $this->expectException(InvalidMd5Exception::class); |
|
| 43 | ||
| 44 | new Md5ValueObject($data); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 8-47 (lines=40) @@ | ||
| 5 | use PhpValueObjects\Identity\Exception\InvalidSha1Exception; |
|
| 6 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 7 | ||
| 8 | class Sha1ValueObjectTest extends BaseUnitTestCase |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @test |
|
| 12 | */ |
|
| 13 | public function itShouldReturnSha1() |
|
| 14 | { |
|
| 15 | $sha1 = $this->faker()->sha1; |
|
| 16 | ||
| 17 | $sha1VO = new Sha1ValueObject($sha1); |
|
| 18 | ||
| 19 | $this->assertSame($sha1, $sha1VO->value()); |
|
| 20 | $this->assertSame($sha1, $sha1VO->__toString()); |
|
| 21 | } |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @return array |
|
| 25 | */ |
|
| 26 | public function invalidSha1Provider() |
|
| 27 | { |
|
| 28 | return [ |
|
| 29 | [null], |
|
| 30 | [$this->faker()->md5], |
|
| 31 | [$this->faker()->sha256], |
|
| 32 | [$this->faker()->text], |
|
| 33 | ]; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @test |
|
| 38 | * |
|
| 39 | * @dataProvider invalidSha1Provider |
|
| 40 | */ |
|
| 41 | public function itShouldThrowsException($data) |
|
| 42 | { |
|
| 43 | $this->expectException(InvalidSha1Exception::class); |
|
| 44 | ||
| 45 | new Sha1ValueObject($data); |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| @@ 8-46 (lines=39) @@ | ||
| 5 | use PhpValueObjects\Identity\Exception\InvalidSha256Exception; |
|
| 6 | use PhpValueObjects\Tests\BaseUnitTestCase; |
|
| 7 | ||
| 8 | class Sha256ValueObjectTest extends BaseUnitTestCase |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @test |
|
| 12 | */ |
|
| 13 | public function itShouldReturnSha256() |
|
| 14 | { |
|
| 15 | $sha256 = $this->faker()->sha256; |
|
| 16 | ||
| 17 | $sha256VO = new Sha256ValueObject($sha256); |
|
| 18 | ||
| 19 | $this->assertSame($sha256, $sha256VO->value()); |
|
| 20 | $this->assertSame($sha256, $sha256VO->__toString()); |
|
| 21 | } |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @return array |
|
| 25 | */ |
|
| 26 | public function invalidSha256Provider() |
|
| 27 | { |
|
| 28 | return [ |
|
| 29 | [null], |
|
| 30 | [$this->faker()->md5], |
|
| 31 | [$this->faker()->sha1], |
|
| 32 | [$this->faker()->text], |
|
| 33 | ]; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @test |
|
| 38 | * @dataProvider invalidSha256Provider |
|
| 39 | */ |
|
| 40 | public function itShouldThrowsException($data) |
|
| 41 | { |
|
| 42 | $this->expectException(InvalidSha256Exception::class); |
|
| 43 | ||
| 44 | new Sha256ValueObject($data); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||