-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0cecdd
commit f56d864
Showing
8 changed files
with
1,295 additions
and
996 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PrinsFrank\Standards\Tests\Unit\CountryShort; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PrinsFrank\Standards\CountryShort\CountryAlpha2; | ||
use TypeError; | ||
|
||
/** | ||
* @coversDefaultClass \PrinsFrank\Standards\CountryShort\CountryAlpha2 | ||
*/ | ||
class CountryAlpha2Test extends TestCase | ||
{ | ||
/** | ||
* @covers ::toISO3166_1_Alpha_3 | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Alpha3(): void | ||
{ | ||
$cases = CountryAlpha2::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_1_Alpha_3(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_3', $case->name)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @covers ::toISO3166_1_Numeric | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Numeric(): void | ||
{ | ||
$cases = CountryAlpha2::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_1_Numeric(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Numeric', $case->name)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @covers ::toISO3166_Name | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Name(): void | ||
{ | ||
$cases = CountryAlpha2::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_Name(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Name', $case->name)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @covers ::lowerCaseValue | ||
*/ | ||
public function testLowerCaseValue(): void | ||
{ | ||
static::assertSame('af', CountryAlpha2::Afghanistan->lowerCaseValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PrinsFrank\Standards\Tests\Unit\CountryShort; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PrinsFrank\Standards\CountryShort\CountryAlpha3; | ||
use TypeError; | ||
|
||
/** | ||
* @coversDefaultClass \PrinsFrank\Standards\CountryShort\CountryAlpha3 | ||
*/ | ||
class CountryAlpha3Test extends TestCase | ||
{ | ||
/** | ||
* @covers ::toISO3166_1_Alpha_2 | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Alpha2(): void | ||
{ | ||
$cases = CountryAlpha3::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_1_Alpha_2(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_2', $case->name)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @covers ::toISO3166_1_Numeric | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Numeric(): void | ||
{ | ||
$cases = CountryAlpha3::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_1_Numeric(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Numeric', $case->name)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @covers ::toISO3166_Name | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Name(): void | ||
{ | ||
$cases = CountryAlpha3::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_Name(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Name', $case->name)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @covers ::lowerCaseValue | ||
*/ | ||
public function testLowerCaseValue(): void | ||
{ | ||
static::assertSame('afg', CountryAlpha3::Afghanistan->lowerCaseValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PrinsFrank\Standards\Tests\Unit\CountryShort; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PrinsFrank\Standards\CountryShort\CountryName; | ||
use TypeError; | ||
|
||
/** | ||
* @coversDefaultClass \PrinsFrank\Standards\Country\ISO3166_1_Name | ||
*/ | ||
class CountryNameTest extends TestCase | ||
{ | ||
/** | ||
* @covers ::toISO3166_1_Alpha_2 | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Alpha2(): void | ||
{ | ||
$cases = CountryName::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_1_Alpha_2(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_2', $case->name)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @covers ::toISO3166_1_Alpha_3 | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Alpha3(): void | ||
{ | ||
$cases = CountryName::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_1_Alpha_3(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_3', $case->name)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @covers ::toISO3166_1_Numeric | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Numeric(): void | ||
{ | ||
$cases = CountryName::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_1_Numeric(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Numeric', $case->name)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PrinsFrank\Standards\Tests\Unit\CountryShort; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PrinsFrank\Standards\CountryShort\CountryNumeric; | ||
use TypeError; | ||
use ValueError; | ||
|
||
/** | ||
* @coversDefaultClass \PrinsFrank\Standards\CountryShort\CountryNumeric | ||
*/ | ||
class CountryNumericTest extends TestCase | ||
{ | ||
/** | ||
* @covers ::toISO3166_1_Alpha_2 | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Alpha2(): void | ||
{ | ||
$cases = CountryNumeric::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_1_Alpha_2(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_2', $case->name)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @covers ::toISO3166_1_Alpha_3 | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Alpha3(): void | ||
{ | ||
$cases = CountryNumeric::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_1_Alpha_3(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_3', $case->name)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @covers ::toISO3166_Name | ||
*/ | ||
public function testAllCasesCanBeConvertedToISO3166Name(): void | ||
{ | ||
$cases = CountryNumeric::cases(); | ||
static::assertNotEmpty($cases); | ||
foreach ($cases as $case) { | ||
try { | ||
$case->toISO3166_Name(); | ||
} catch (TypeError) { | ||
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Name', $case->name)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @covers ::fromInt | ||
*/ | ||
public function testFromInt(): void | ||
{ | ||
static::assertEquals(CountryNumeric::Albania, CountryNumeric::fromInt(8)); | ||
} | ||
|
||
/** | ||
* @covers ::fromInt | ||
*/ | ||
public function testFromIntThrowsExceptionOnNonExistingValue(): void | ||
{ | ||
$this->expectException(ValueError::class); | ||
static::assertNull(CountryNumeric::fromInt(1)); | ||
} | ||
|
||
/** | ||
* @covers ::tryFromInt | ||
*/ | ||
public function testTryFromInt(): void | ||
{ | ||
static::assertEquals(CountryNumeric::Albania, CountryNumeric::tryFromInt(8)); | ||
static::assertNull(CountryNumeric::tryFromInt(1)); | ||
} | ||
|
||
/** | ||
* @covers ::valueAsInt | ||
*/ | ||
public function testValueAsInt(): void | ||
{ | ||
static::assertSame(4, CountryNumeric::Afghanistan->valueAsInt()); | ||
} | ||
} |