public function testToString($value, $currencyCode, $expectedOutput) { if (Intl::isExtensionLoaded()) { \Locale::setDefault('en'); } $this->if($price = new TestedPrice($value, $currencyCode))->string((string) $price)->isIdenticalTo($expectedOutput); }
/** * Should be called before tests that require a feature-complete intl * implementation. * * @param \PhpUnit_Framework_TestCase $testCase */ public static function requireFullIntl(\PhpUnit_Framework_TestCase $testCase) { // We only run tests if the intl extension is loaded... if (!Intl::isExtensionLoaded()) { $testCase->markTestSkipped('The intl extension is not available.'); } // ... and only if the version is *one specific version* ... if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', $precision = 1)) { $testCase->markTestSkipped('Please change ICU version to ' . Intl::getIcuStubVersion()); } // ... and only if the data in the Icu component matches that version. if (IcuVersion::compare(Intl::getIcuDataVersion(), Intl::getIcuStubVersion(), '!=', $precision = 1)) { $testCase->markTestSkipped('Please change the Icu component to version 1.0.x or 1.' . IcuVersion::normalize(Intl::getIcuStubVersion(), 1) . '.x'); } // Normalize the default locale in case this is not done explicitly // in the test \Locale::setDefault('en'); // Consequently, tests will // // * run only for one ICU version (see Intl::getIcuStubVersion()) // there is no need to add control structures to your tests that // change the test depending on the ICU version. // * always use the C intl classes // * always use the binary resource bundles (any locale is allowed) }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $countryRepository = $this->getCountryRepository(); $countries = Intl::getRegionBundle()->getCountryNames($this->defaultLocale); if (Intl::isExtensionLoaded()) { $localisedCountries = array('es_ES' => Intl::getRegionBundle()->getCountryNames('es_ES')); } else { $localisedCountries = array(); } foreach ($countries as $isoName => $name) { $country = $countryRepository->createNew(); $country->setCurrentLocale($this->defaultLocale); $country->setName($name); foreach ($localisedCountries as $locale => $translatedCountries) { $country->setCurrentLocale($locale); $country->setName($translatedCountries[$isoName]); } $country->setIsoName($isoName); if ('US' === $isoName) { $this->addUsStates($country); } $manager->persist($country); $this->setReference('Sylius.Country.' . $isoName, $country); } $manager->flush(); }
protected function setUp() { // We only run tests if the intl extension is loaded... if (!Intl::isExtensionLoaded()) { $this->markTestSkipped('The intl extension is not available.'); } $this->reader = new IntlBundleReader(); }
protected function setUp() { if (!Intl::isExtensionLoaded()) { $this->markTestSkipped('The intl extension is not available.'); } if (IcuVersion::compare(Intl::getIcuVersion(), '4.4', '<', $precision = 1)) { $this->markTestSkipped('Please change your ICU version to 4.4 or higher'); } }
public function testWriteResourceBundle() { // We only run tests if the intl extension is loaded... if (!Intl::isExtensionLoaded()) { $this->markTestSkipped('The intl extension is not available.'); } $bundle = new \ResourceBundle('rb', __DIR__ . '/Fixtures', false); $this->writer->write($this->directory, 'en', $bundle); $this->assertFileEquals(__DIR__ . '/Fixtures/rb.json', $this->directory . '/en.json'); }
private function buildFormatter($locale) { if (!Intl::isExtensionLoaded()) { // This number formatter don't have exactly the same behavior $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); } else { $formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY); } return $formatter; }
public function getFormatter() { if (null === $this->formatter) { if (!Intl::isExtensionLoaded()) { // This number formatter don't have exactly the same behavior $this->formatter = new NumberFormatter('en', NumberFormatter::CURRENCY); } else { $this->formatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::CURRENCY); } } return $this->formatter; }
public function testWriteResourceBundle() { // We only run tests if the intl extension is loaded... if (!Intl::isExtensionLoaded()) { $this->markTestSkipped('The intl extension is not available.'); } if (PHP_VERSION_ID < 50315 || PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404) { $this->markTestSkipped('ResourceBundle implements Traversable only as of PHP 5.3.15 and 5.4.4'); } $bundle = new \ResourceBundle('rb', __DIR__ . '/Fixtures', false); $this->writer->write($this->directory, 'en', $bundle); $this->assertFileEquals(__DIR__ . '/Fixtures/rb.php', $this->directory . '/en.php'); }
/** * Should be called before tests that require a feature-complete intl * implementation. */ public static function requireFullIntl(\PHPUnit_Framework_TestCase $testCase, $minimumIcuVersion = null) { // We only run tests if the intl extension is loaded... if (!Intl::isExtensionLoaded()) { $testCase->markTestSkipped('Extension intl is required.'); } self::requireIntl($testCase, $minimumIcuVersion); // Consequently, tests will // // * run only for one ICU version (see Intl::getIcuStubVersion()) // there is no need to add control structures to your tests that // change the test depending on the ICU version. // * always use the C intl classes }
/** * Should be called before tests that require a feature-complete intl * implementation. * * @param \PhpUnit_Framework_TestCase $testCase */ public static function requireFullIntl(\PHPUnit_Framework_TestCase $testCase) { // We only run tests if the intl extension is loaded... if (!Intl::isExtensionLoaded()) { $testCase->markTestSkipped('Extension intl is required.'); } // ... and only if the version is *one specific version* if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', 1)) { $testCase->markTestSkipped('ICU version ' . Intl::getIcuStubVersion() . ' is required.'); } // Normalize the default locale in case this is not done explicitly // in the test \Locale::setDefault('en'); // Consequently, tests will // // * run only for one ICU version (see Intl::getIcuStubVersion()) // there is no need to add control structures to your tests that // change the test depending on the ICU version. // * always use the C intl classes }
If you also built the repository before, you can pass the directory where that build is stored in the second parameter. The build directory needs to contain the subdirectories bin/ and lib/. For running this script, the intl extension must be loaded and all vendors must have been installed through composer: composer install MESSAGE ); } echo LINE; echo centered('ICU Resource Bundle Compilation') . "\n"; echo LINE; if (!Intl::isExtensionLoaded()) { bailout('The intl extension for PHP is not installed.'); } $filesystem = new Filesystem(); $urls = parse_ini_file(__DIR__ . '/icu.ini'); echo "icu.ini parsed. Available versions:\n"; $maxVersion = 0; foreach ($urls as $urlVersion => $url) { $maxVersion = IcuVersion::compare($maxVersion, $urlVersion, '<') ? $urlVersion : $maxVersion; echo " {$urlVersion}\n"; } $shortIcuVersion = strip_minor_versions($maxVersion); if ($argc >= 2) { $sourceDir = $argv[1]; $svn = new SvnRepository($sourceDir); echo "Using existing SVN repository at {$sourceDir}.\n";
protected function setUp() { if (!Intl::isExtensionLoaded()) { $this->markTestSkipped('The intl extension is not available.'); } }