From 2a21787ad46fb118fac767c0532af14adabbd741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 1 Dec 2016 15:53:11 +0100 Subject: [PATCH] add function to get countries by continent The class Util::Country info return countries code by continent --- Tests/Util/CountriesInfoTest.php | 48 ++++ Util/CountriesInfo.php | 361 +++++++++++++++++++++++++++++++ 2 files changed, 409 insertions(+) create mode 100644 Tests/Util/CountriesInfoTest.php create mode 100644 Util/CountriesInfo.php diff --git a/Tests/Util/CountriesInfoTest.php b/Tests/Util/CountriesInfoTest.php new file mode 100644 index 000000000..955ec4382 --- /dev/null +++ b/Tests/Util/CountriesInfoTest.php @@ -0,0 +1,48 @@ +assertStringStartsWith("AS AF AFG 004 Afghanistan, Islamic Republic of", + $raw); + } + + public function testGetArrayCountriesData() + { + $data = CountriesInfo::getArrayCountriesData(); + + $this->assertNotNull($data); + $this->assertContains(array( + "AS", "AF", "AFG", "004", "Afghanistan, Islamic Republic of" + ), $data); + } + + public function testGetCountryCodeByContinents() + { + $countries = CountriesInfo::getCountriesCodeByContinent('EU'); + + $this->assertContains('BE', $countries); + $this->assertContains('FR', $countries); + $this->assertContains('GB', $countries); + } + + public function getGetContinentsCodes() + { + $continents = CountriesInfo::getContinentsCodes(); + + $this->assertContains('EU', $continents); + } +} diff --git a/Util/CountriesInfo.php b/Util/CountriesInfo.php new file mode 100644 index 000000000..a6dfbee49 --- /dev/null +++ b/Util/CountriesInfo.php @@ -0,0 +1,361 @@ +