From 801acdb08f4961850d80cdcf1829b5d48bddd71b Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Thu, 6 Nov 2025 21:24:23 +0000 Subject: [PATCH 1/6] add test --- tests/Country/CountryTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/Country/CountryTest.php diff --git a/tests/Country/CountryTest.php b/tests/Country/CountryTest.php new file mode 100644 index 0000000..55a7236 --- /dev/null +++ b/tests/Country/CountryTest.php @@ -0,0 +1,15 @@ +getName()); + } +} From b9ce65b57d4ba50148220957cb9f2eb87832c181 Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Thu, 6 Nov 2025 21:30:17 +0000 Subject: [PATCH 2/6] positive test --- tests/Country/CountryTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/Country/CountryTest.php b/tests/Country/CountryTest.php index 55a7236..0c96fad 100644 --- a/tests/Country/CountryTest.php +++ b/tests/Country/CountryTest.php @@ -9,6 +9,9 @@ class CountryTest extends TestCase { public function testCountry() { + $us = CountryHelper::getCountry('US'); + self::assertEquals('United States', $us->getName()); + $us = CountryHelper::getCountry('us'); self::assertEquals('United States', $us->getName()); } From 955566d789f45a9341a192c3bada0d9bb1894445 Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Thu, 6 Nov 2025 21:33:10 +0000 Subject: [PATCH 3/6] split test --- tests/Country/CountryTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Country/CountryTest.php b/tests/Country/CountryTest.php index 0c96fad..8e1b5f5 100644 --- a/tests/Country/CountryTest.php +++ b/tests/Country/CountryTest.php @@ -7,11 +7,14 @@ class CountryTest extends TestCase { - public function testCountry() + public function testCountryUppercase() { $us = CountryHelper::getCountry('US'); self::assertEquals('United States', $us->getName()); + } + public function testCountryLowercase() + { $us = CountryHelper::getCountry('us'); self::assertEquals('United States', $us->getName()); } From 715cd084e386d7151a9660b5aeae2687620f2dad Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Thu, 6 Nov 2025 21:35:07 +0000 Subject: [PATCH 4/6] test lowercase first uppercase first loads the class, then lowercase test passes --- tests/Country/CountryTest.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/Country/CountryTest.php b/tests/Country/CountryTest.php index 8e1b5f5..9c9e57d 100644 --- a/tests/Country/CountryTest.php +++ b/tests/Country/CountryTest.php @@ -7,15 +7,12 @@ class CountryTest extends TestCase { - public function testCountryUppercase() - { - $us = CountryHelper::getCountry('US'); - self::assertEquals('United States', $us->getName()); - } - public function testCountryLowercase() { $us = CountryHelper::getCountry('us'); self::assertEquals('United States', $us->getName()); + + $us = CountryHelper::getCountry('US'); + self::assertEquals('United States', $us->getName()); } } From 52f5f1b06825ac03b78baaf80c07bbc3885f2f20 Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Thu, 6 Nov 2025 21:35:42 +0000 Subject: [PATCH 5/6] fix --- src/Country/CountryHelper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Country/CountryHelper.php b/src/Country/CountryHelper.php index e6aca0f..0ec54f6 100644 --- a/src/Country/CountryHelper.php +++ b/src/Country/CountryHelper.php @@ -44,6 +44,10 @@ class CountryHelper public static function getCountry($code, $default = null) { $code = $code ?: $default; + if(is_string($code)) + { + $code = strtoupper($code); + } $className = sprintf('\Packaged\Rwd\Country\Countries\%sCountry', $code); if(class_exists($className)) { From 6a996d4784e65b90ba1c0f76e39afca14c49643b Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Thu, 6 Nov 2025 21:37:42 +0000 Subject: [PATCH 6/6] update actions --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4a25a8..dd02dd7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,9 +7,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 - uses: php-actions/composer@v6 - - uses: php-actions/phpunit@v3 + - uses: php-actions/phpunit@v4 with: configuration: ./phpunit.xml php_version: 7.4