| @@ 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 | ||