Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17a480b

Browse files
committed
[Intl] Added IntlTestHelper class for convenience
1 parent 1dcdcd3 commit 17a480b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Intl\Util;
13+
14+
use Symfony\Component\Intl\Intl;
15+
16+
/**
17+
* Helper class for preparing test cases that rely on the Intl component.
18+
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*/
21+
class IntlTestHelper
22+
{
23+
/**
24+
* Prepares the given test case to use the Intl component.
25+
*
26+
* @param \PhpUnit_Framework_TestCase $testCase
27+
*/
28+
public static function setUp(\PhpUnit_Framework_TestCase $testCase)
29+
{
30+
if (!Intl::isExtensionLoaded()) {
31+
$testCase->markTestSkipped('The intl extension is not available.');
32+
}
33+
34+
if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', $precision = 1)) {
35+
$testCase->markTestSkipped('Please change ICU version to ' . Intl::getIcuStubVersion());
36+
}
37+
38+
Intl::setDataSource(Intl::STUB);
39+
40+
\Locale::setDefault('en');
41+
}
42+
/**
43+
* Must not be instantiated.
44+
*/
45+
private function __construct() {}
46+
}

0 commit comments

Comments
 (0)