Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| LanguageRegionTest | |
0.00% |
0 / 16 |
|
0.00% |
0 / 7 |
56 | |
0.00% |
0 / 1 |
| it_can_be_instantiated_with_a_valid_tag | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| it_can_be_instantiated_with_a_deprecated_tag | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| it_can_return_a_preferred_value | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| it_returns_itself_if_no_preferred_value | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| it_throws_an_exception_with_an_invalid_tag | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| it_can_be_instantiated_with_an_active_tag | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| it_throws_an_exception_with_a_deprecated_tag_when_active_required | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\Tests\IanaValueObjects; |
| 3 | |
| 4 | use Apie\Core\ValueObjects\Exceptions\InvalidStringForValueObjectException; |
| 5 | use Apie\IanaValueObjects\ActiveLanguageRegion; |
| 6 | use Apie\IanaValueObjects\LanguageRegion; |
| 7 | use PHPUnit\Framework\Attributes\Test; |
| 8 | use PHPUnit\Framework\TestCase; |
| 9 | |
| 10 | class LanguageRegionTest extends TestCase |
| 11 | { |
| 12 | #[Test] |
| 13 | public function it_can_be_instantiated_with_a_valid_tag() |
| 14 | { |
| 15 | $testItem = new LanguageRegion('bE'); |
| 16 | $this->assertEquals('BE', $testItem->toNative()); |
| 17 | } |
| 18 | |
| 19 | #[Test] |
| 20 | public function it_can_be_instantiated_with_a_deprecated_tag() |
| 21 | { |
| 22 | $testItem = new LanguageRegion('BU'); |
| 23 | $this->assertEquals('BU', $testItem->toNative()); |
| 24 | } |
| 25 | |
| 26 | #[Test] |
| 27 | public function it_can_return_a_preferred_value() |
| 28 | { |
| 29 | $testItem = new LanguageRegion('bu'); |
| 30 | $preferred = $testItem->toPreferredValue(); |
| 31 | $this->assertEquals('MM', $preferred->toNative()); |
| 32 | } |
| 33 | |
| 34 | #[Test] |
| 35 | public function it_returns_itself_if_no_preferred_value() |
| 36 | { |
| 37 | $testItem = new LanguageRegion('be'); |
| 38 | $preferred = $testItem->toPreferredValue(); |
| 39 | $this->assertEquals('BE', $preferred->toNative()); |
| 40 | } |
| 41 | |
| 42 | #[Test] |
| 43 | public function it_throws_an_exception_with_an_invalid_tag() |
| 44 | { |
| 45 | $this->expectException(InvalidStringForValueObjectException::class); |
| 46 | new LanguageRegion('invalid'); |
| 47 | } |
| 48 | |
| 49 | #[Test] |
| 50 | public function it_can_be_instantiated_with_an_active_tag() |
| 51 | { |
| 52 | $testItem = new ActiveLanguageRegion('bs'); |
| 53 | $this->assertEquals('BS', $testItem->toNative()); |
| 54 | } |
| 55 | |
| 56 | #[Test] |
| 57 | public function it_throws_an_exception_with_a_deprecated_tag_when_active_required() |
| 58 | { |
| 59 | $this->expectException(InvalidStringForValueObjectException::class); |
| 60 | new ActiveLanguageRegion('bu'); |
| 61 | } |
| 62 | } |