add function to get countries by continent

The class Util::Country info return countries code by continent
This commit is contained in:
2016-12-01 15:53:11 +01:00
parent 34c0ff3ba1
commit 2a21787ad4
2 changed files with 409 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
<?php
namespace Chill\MainBundle\Tests\Util;
use PHPUnit\Framework\TestCase;
use Chill\MainBundle\Util\CountriesInfo;
/**
* tests for CountriesInfos
*
* @author julien.fastre@champs-libre.coop
*/
class CountriesInfoTest extends TestCase {
public function testGetCountryData()
{
$raw = CountriesInfo::getCountriesData();
$this->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);
}
}