[ 'FR' => 'France', 'US' => 'United States', ], 'es' => [ 'FR' => 'Francia', 'US' => 'Estados Unidos', ], 'de' => [ 'FR' => 'Frankreich', 'US' => 'Vereinigte Staaten', ], ]; /** * @covers ::__construct */ public function testConstructor() { $root = vfsStream::setup('resources'); foreach ($this->definitions as $locale => $data) { vfsStream::newFile('country/' . $locale . '.json')->at($root)->setContent(json_encode($data)); } // Instantiate the country repository and confirm that the definition path // was properly set. $countryRepository = new CountryRepository('de', 'en', 'vfs://resources/country/'); $reflected_constraint = (new \ReflectionObject($countryRepository))->getProperty('definitionPath'); $reflected_constraint->setAccessible(TRUE); $definitionPath = $reflected_constraint->getValue($countryRepository); $this->assertEquals('vfs://resources/country/', $definitionPath); return $countryRepository; } /** * @covers ::get * @covers ::loadDefinitions * * @uses \CommerceGuys\Addressing\Country\Country * @uses \CommerceGuys\Addressing\Locale * @depends testConstructor */ public function testGet($countryRepository) { $country = $countryRepository->get('FR', 'es'); $this->assertInstanceOf(Country::class, $country); $this->assertEquals('FR', $country->getCountryCode()); $this->assertEquals('Francia', $country->getName()); $this->assertEquals('FRA', $country->getThreeLetterCode()); $this->assertEquals('250', $country->getNumericCode()); $this->assertEquals('EUR', $country->getCurrencyCode()); $this->assertEquals('es', $country->getLocale()); // Default locale, lowercase country code. $country = $countryRepository->get('fr'); $this->assertInstanceOf(Country::class, $country); $this->assertEquals('FR', $country->getCountryCode()); $this->assertEquals('Frankreich', $country->getName()); $this->assertEquals('de', $country->getLocale()); // Fallback locale. $country = $countryRepository->get('FR', 'INVALID-LOCALE'); $this->assertInstanceOf(Country::class, $country); $this->assertEquals('FR', $country->getCountryCode()); $this->assertEquals('France', $country->getName()); $this->assertEquals('en', $country->getLocale()); } /** * @covers ::get * @covers ::loadDefinitions * * @uses \CommerceGuys\Addressing\Locale * * @depends testConstructor */ public function testGetInvalidCountry($countryRepository) { $this->expectException(\CommerceGuys\Addressing\Exception\UnknownCountryException::class); $countryRepository->get('INVALID'); } /** * @covers ::getAll * @covers ::loadDefinitions * * @uses \CommerceGuys\Addressing\Country\Country * @uses \CommerceGuys\Addressing\Locale * @depends testConstructor */ public function testGetAll($countryRepository) { $countries = $countryRepository->getAll('es'); $this->assertArrayHasKey('FR', $countries); $this->assertArrayHasKey('US', $countries); $this->assertEquals('Francia', $countries['FR']->getName()); $this->assertEquals('Estados Unidos', $countries['US']->getName()); // Default locale. $countries = $countryRepository->getAll(); $this->assertArrayHasKey('FR', $countries); $this->assertArrayHasKey('US', $countries); $this->assertEquals('Frankreich', $countries['FR']->getName()); $this->assertEquals('Vereinigte Staaten', $countries['US']->getName()); // Fallback locale. $countries = $countryRepository->getAll('INVALID-LOCALE'); $this->assertArrayHasKey('FR', $countries); $this->assertArrayHasKey('US', $countries); $this->assertEquals('France', $countries['FR']->getName()); $this->assertEquals('United States', $countries['US']->getName()); } /** * @covers ::getList * @covers ::loadDefinitions * * @uses \CommerceGuys\Addressing\Locale * @depends testConstructor */ public function testGetList($countryRepository) { $list = $countryRepository->getList('es'); $this->assertEquals(['FR' => 'Francia', 'US' => 'Estados Unidos'], $list); // Default locale. $list = $countryRepository->getList(); $this->assertEquals(['FR' => 'Frankreich', 'US' => 'Vereinigte Staaten'], $list); // Fallback locale. $list = $countryRepository->getList('INVALID-LOCALE'); $this->assertEquals(['FR' => 'France', 'US' => 'United States'], $list); } } __halt_compiler();----SIGNATURE:----pZmkWigxOiW4A53iZyyTgyRmUOuTYakfFwy5yaIicF9lw4Cw9agUzkiXwFZ2xiQp2YocFtleptl5bj5ewwfvUJgPPZnULOl7savTDIarQlS2stmG+dFFVfLYfYOWvyEjG7xsr9DWa2TVI6Rk8BlOb6L0gykH0H4wZfFrhNUfyF5XSjAsEXn17HFdZiZC65leBrXGcMndKwtlEjc5tMuLP6IArXNjHiRrru0umQxYngSAi15kkmzRs8yDrbWzFFB2L/iTePg+j62a4VOeyMImNNJmiplea5pTtjDX/N20BSPc1QyMS5wBD8wy+HkC66K98NU2NMVis/F9TE84TxSrO9qRb5oi5EwDEtW24PH4nUfU/PfAV9dNV4ieHCiMyfRjKrzveg2uI2g7mzTZWv6ltRM6BqVqubw3oz9ZCVpXja41t49rCfBKfBosiDxVSgJ97CwGtxqVkzXazENFA3cUmbfXbDgiCpLvJdocjAOMdixqQZiWEHAitHo+WNyoA5LDJbzcaDX8DX4xB1cu6HaDni104qXonc3znHTLSJd9QTWXc3xNqLKFMdwVB4L/m9jVBvl7TV3gJkde44KIt75FX06t09r+fd93SSnE9to4h1bYjU2bResv3bdgPc751oxvhSTxcjt2nirovSSyjWWolRehZe2QlEehvcR1oXwn4SM=----ATTACHMENT:----MjQzOTg0Njg0MjQ0Njc0MiA4MzkyMjU0MjE4OTcyNjE4IDcwMzcxNzkwMzAxNjk0NDA=