コード例 #1
0
ファイル: IntlTestHelper.php プロジェクト: yceruto/symfony
 /**
  * Should be called before tests that work fine with the stub implementation.
  */
 public static function requireIntl(\PHPUnit_Framework_TestCase $testCase, $minimumIcuVersion = null)
 {
     if (null === $minimumIcuVersion) {
         $minimumIcuVersion = Intl::getIcuStubVersion();
     }
     // We only run tests if the version is *one specific version*.
     // This condition is satisfied if
     //
     //   * the intl extension is loaded with version Intl::getIcuStubVersion()
     //   * the intl extension is not loaded
     if (($minimumIcuVersion || defined('HHVM_VERSION_ID')) && IcuVersion::compare(Intl::getIcuVersion(), $minimumIcuVersion, '!=', 1)) {
         $testCase->markTestSkipped('ICU version ' . $minimumIcuVersion . ' 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.
     //
     // Tests should only rely on functionality that is implemented in the
     // stub classes.
 }
コード例 #2
0
 /**
  * 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)
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function beforeCompile(CompilationContextInterface $context)
 {
     // The language data is contained in the locales bundle in ICU <= 4.2
     if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) {
         return $context->getSourceDir() . '/locales';
     }
     return $context->getSourceDir() . '/lang';
 }
コード例 #4
0
ファイル: IcuTestCase.php プロジェクト: acappel01/opencall
 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');
     }
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function beforeCompile(CompilationContextInterface $context)
 {
     // The currency data is contained in the locales and misc bundles
     // in ICU <= 4.2
     if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) {
         return array($context->getSourceDir() . '/misc/supplementalData.txt', $context->getSourceDir() . '/locales');
     }
     return $context->getSourceDir() . '/curr';
 }
コード例 #6
0
ファイル: IntlTestHelper.php プロジェクト: unexge/symfony
 /**
  * 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
 }
コード例 #7
0
ファイル: update-data.php プロジェクト: Ener-Getick/symfony
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";
} else {
    echo "Starting SVN checkout for version {$shortIcuVersion}. This may take a while...\n";
    $sourceDir = sys_get_temp_dir() . '/icu-data/' . $shortIcuVersion . '/source';
    $svn = SvnRepository::download($urls[$shortIcuVersion], $sourceDir);
    echo "SVN checkout to {$sourceDir} complete.\n";
}
if ($argc >= 3) {
    $buildDir = $argv[2];
コード例 #8
0
 /**
  * @dataProvider compareProvider
  */
 public function testCompare($precision, $version1, $operator, $version2, $result)
 {
     $this->assertSame($result, IcuVersion::compare($version1, $version2, $operator, $precision));
 }