[Intl] Added IntlTestHelper class for convenience
This commit is contained in:
parent
1dcdcd38cd
commit
17a480b285
46
src/Symfony/Component/Intl/Util/IntlTestHelper.php
Normal file
46
src/Symfony/Component/Intl/Util/IntlTestHelper.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Intl\Util;
|
||||
|
||||
use Symfony\Component\Intl\Intl;
|
||||
|
||||
/**
|
||||
* Helper class for preparing test cases that rely on the Intl component.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class IntlTestHelper
|
||||
{
|
||||
/**
|
||||
* Prepares the given test case to use the Intl component.
|
||||
*
|
||||
* @param \PhpUnit_Framework_TestCase $testCase
|
||||
*/
|
||||
public static function setUp(\PhpUnit_Framework_TestCase $testCase)
|
||||
{
|
||||
if (!Intl::isExtensionLoaded()) {
|
||||
$testCase->markTestSkipped('The intl extension is not available.');
|
||||
}
|
||||
|
||||
if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', $precision = 1)) {
|
||||
$testCase->markTestSkipped('Please change ICU version to ' . Intl::getIcuStubVersion());
|
||||
}
|
||||
|
||||
Intl::setDataSource(Intl::STUB);
|
||||
|
||||
\Locale::setDefault('en');
|
||||
}
|
||||
/**
|
||||
* Must not be instantiated.
|
||||
*/
|
||||
private function __construct() {}
|
||||
}
|
Reference in New Issue
Block a user