[Intl] Removed "Stub" prefix from stub classes

This commit is contained in:
Bernhard Schussek 2013-04-11 11:28:48 +02:00
parent 60f31d1004
commit b4cccfd9b6
20 changed files with 230 additions and 239 deletions

View File

@ -13,8 +13,8 @@ namespace Symfony\Component\Intl\Collator;
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
use Symfony\Component\Intl\Globals\StubIntlGlobals;
use Symfony\Component\Intl\Locale\StubLocale;
use Symfony\Component\Intl\Globals\IntlGlobals;
use Symfony\Component\Intl\Locale\Locale;
/**
* Replacement for PHP's native {@link \Collator} class.
@ -31,7 +31,7 @@ use Symfony\Component\Intl\Locale\StubLocale;
* @author Igor Wiedler <igor@wiedler.ch>
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class StubCollator
class Collator
{
/* Attribute constants */
const FRENCH_COLLATION = 0;
@ -86,7 +86,7 @@ class StubCollator
*
* @param string $locale The locale code. The only currently supported locale is "en".
*
* @return StubCollator
* @return Collator
*
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed
*/
@ -100,9 +100,9 @@ class StubCollator
*
* @param array &$array Input array
* @param integer $sortFlag Flags for sorting, can be one of the following:
* StubCollator::SORT_REGULAR - compare items normally (don't change types)
* StubCollator::SORT_NUMERIC - compare items numerically
* StubCollator::SORT_STRING - compare items as strings
* Collator::SORT_REGULAR - compare items normally (don't change types)
* Collator::SORT_NUMERIC - compare items numerically
* Collator::SORT_STRING - compare items as strings
*
* @return Boolean True on success or false on failure
*/
@ -162,7 +162,7 @@ class StubCollator
*/
public function getErrorCode()
{
return StubIntlGlobals::U_ZERO_ERROR;
return IntlGlobals::U_ZERO_ERROR;
}
/**
@ -183,7 +183,7 @@ class StubCollator
* @return string The locale used to create the collator. Currently always
* returns "en".
*/
public function getLocale($type = StubLocale::ACTUAL_LOCALE)
public function getLocale($type = Locale::ACTUAL_LOCALE)
{
return 'en';
}
@ -239,12 +239,12 @@ class StubCollator
* Not supported. Set the collator's strength
*
* @param int $strength Strength to set, possible values:
* StubCollator::PRIMARY
* StubCollator::SECONDARY
* StubCollator::TERTIARY
* StubCollator::QUATERNARY
* StubCollator::IDENTICAL
* StubCollator::DEFAULT
* Collator::PRIMARY
* Collator::SECONDARY
* Collator::TERTIARY
* Collator::QUATERNARY
* Collator::IDENTICAL
* Collator::DEFAULT
*
* @return Boolean True on success or false on failure
*
@ -278,9 +278,9 @@ class StubCollator
*
* @param array &$arr Array of string to sort
* @param int $sortFlag Optional sorting type, one of the following:
* StubCollator::SORT_REGULAR
* StubCollator::SORT_NUMERIC
* StubCollator::SORT_STRING
* Collator::SORT_REGULAR
* Collator::SORT_NUMERIC
* Collator::SORT_STRING
*
* @return Boolean True on success or false on failure
*

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\Intl\DateFormatter\DateFormat;
use Symfony\Component\Intl\Exception\NotImplementedException;
use Symfony\Component\Intl\Globals\StubIntlGlobals;
use Symfony\Component\Intl\Globals\IntlGlobals;
use Symfony\Component\Intl\DateFormatter\DateFormat\MonthTransformer;
/**
@ -156,13 +156,13 @@ class FullTransformer
}
// reset error code and message
StubIntlGlobals::setError(StubIntlGlobals::U_ZERO_ERROR);
IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);
return $this->calculateUnixTimestamp($dateTime, $options);
}
// behave like the intl extension
StubIntlGlobals::setError(StubIntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
return false;
}
@ -303,7 +303,7 @@ class FullTransformer
// If month is false, return immediately (intl behavior)
if (false === $month) {
StubIntlGlobals::setError(StubIntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
return false;
}

View File

@ -11,12 +11,12 @@
namespace Symfony\Component\Intl\DateFormatter;
use Symfony\Component\Intl\Globals\StubIntlGlobals;
use Symfony\Component\Intl\Globals\IntlGlobals;
use Symfony\Component\Intl\DateFormatter\DateFormat\FullTransformer;
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
use Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException;
use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
use Symfony\Component\Intl\Locale\StubLocale;
use Symfony\Component\Intl\Locale\Locale;
/**
* Replacement for PHP's native {@link \IntlDateFormatter} class.
@ -44,14 +44,14 @@ use Symfony\Component\Intl\Locale\StubLocale;
* @author Igor Wiedler <igor@wiedler.ch>
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class StubIntlDateFormatter
class IntlDateFormatter
{
/**
* The error code from the last operation
*
* @var integer
*/
protected $errorCode = StubIntlGlobals::U_ZERO_ERROR;
protected $errorCode = IntlGlobals::U_ZERO_ERROR;
/**
* The error message from the last operation
@ -171,7 +171,7 @@ class StubIntlDateFormatter
* One of the calendar constants.
* @param string $pattern Optional pattern to use when formatting
*
* @return StubIntlDateFormatter
* @return IntlDateFormatter
*
* @see http://www.php.net/manual/en/intldateformatter.create.php
* @see http://userguide.icu-project.org/formatparse/datetime
@ -219,9 +219,9 @@ class StubIntlDateFormatter
}
if (null !== $argumentError) {
StubIntlGlobals::setError(StubIntlGlobals::U_ILLEGAL_ARGUMENT_ERROR, $argumentError);
$this->errorCode = StubIntlGlobals::getErrorCode();
$this->errorMessage = StubIntlGlobals::getErrorMessage();
IntlGlobals::setError(IntlGlobals::U_ILLEGAL_ARGUMENT_ERROR, $argumentError);
$this->errorCode = IntlGlobals::getErrorCode();
$this->errorMessage = IntlGlobals::getErrorMessage();
return false;
}
@ -235,9 +235,9 @@ class StubIntlDateFormatter
$formatted = $transformer->format($this->createDateTime($timestamp));
// behave like the intl extension
StubIntlGlobals::setError(StubIntlGlobals::U_ZERO_ERROR);
$this->errorCode = StubIntlGlobals::getErrorCode();
$this->errorMessage = StubIntlGlobals::getErrorMessage();
IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);
$this->errorCode = IntlGlobals::getErrorCode();
$this->errorMessage = IntlGlobals::getErrorMessage();
return $formatted;
}
@ -333,7 +333,7 @@ class StubIntlDateFormatter
*
* @see http://www.php.net/manual/en/intldateformatter.getlocale.php
*/
public function getLocale($type = StubLocale::ACTUAL_LOCALE)
public function getLocale($type = Locale::ACTUAL_LOCALE)
{
return 'en';
}
@ -459,8 +459,8 @@ class StubIntlDateFormatter
$timestamp = $transformer->parse($dateTime, $value);
// behave like the intl extension. FullTransformer::parse() set the proper error
$this->errorCode = StubIntlGlobals::getErrorCode();
$this->errorMessage = StubIntlGlobals::getErrorMessage();
$this->errorCode = IntlGlobals::getErrorCode();
$this->errorMessage = IntlGlobals::getErrorMessage();
return $timestamp;
}

View File

@ -16,7 +16,7 @@ namespace Symfony\Component\Intl\Globals;
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
abstract class StubIntlGlobals
abstract class IntlGlobals
{
/**
* Indicates that no error occurred
@ -67,7 +67,7 @@ abstract class StubIntlGlobals
/**
* Returns whether the error code indicates a failure
*
* @param integer $errorCode The error code returned by StubIntlGlobals::getErrorCode()
* @param integer $errorCode The error code returned by IntlGlobals::getErrorCode()
*
* @return Boolean
*/
@ -80,7 +80,7 @@ abstract class StubIntlGlobals
/**
* Returns the error code of the last operation
*
* Returns StubIntlGlobals::U_ZERO_ERROR if no error occurred.
* Returns IntlGlobals::U_ZERO_ERROR if no error occurred.
*
* @return integer
*/
@ -104,7 +104,7 @@ abstract class StubIntlGlobals
/**
* Returns the symbolic name for a given error code
*
* @param integer $code The error code returned by StubIntlGlobals::getErrorCode()
* @param integer $code The error code returned by IntlGlobals::getErrorCode()
*
* @return string
*/

View File

@ -11,7 +11,6 @@
namespace Symfony\Component\Intl\Locale;
use Symfony\Component\Intl\Locale;
use Symfony\Component\Intl\Exception\NotImplementedException;
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
@ -24,7 +23,7 @@ use Symfony\Component\Intl\Exception\MethodNotImplementedException;
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class StubLocale
class Locale
{
const DEFAULT_LOCALE = null;

View File

@ -15,9 +15,9 @@ use Symfony\Component\Intl\Exception\NotImplementedException;
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
use Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException;
use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
use Symfony\Component\Intl\Globals\StubIntlGlobals;
use Symfony\Component\Intl\Globals\IntlGlobals;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Intl\Locale\StubLocale;
use Symfony\Component\Intl\Locale\Locale;
/**
* Replacement for PHP's native {@link \NumberFormatter} class.
@ -38,7 +38,7 @@ use Symfony\Component\Intl\Locale\StubLocale;
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class StubNumberFormatter
class NumberFormatter
{
/* Format style constants */
const PATTERN_DECIMAL = 0;
@ -132,7 +132,7 @@ class StubNumberFormatter
*
* @var integer
*/
protected $errorCode = StubIntlGlobals::U_ZERO_ERROR;
protected $errorCode = IntlGlobals::U_ZERO_ERROR;
/**
* The error message from the last operation
@ -187,8 +187,8 @@ class StubNumberFormatter
/**
* The available rounding modes for setAttribute() usage with
* StubNumberFormatter::ROUNDING_MODE. StubNumberFormatter::ROUND_DOWN
* and StubNumberFormatter::ROUND_UP does not have a PHP only equivalent
* NumberFormatter::ROUNDING_MODE. NumberFormatter::ROUND_DOWN
* and NumberFormatter::ROUND_UP does not have a PHP only equivalent
*
* @var array
*/
@ -280,7 +280,7 @@ class StubNumberFormatter
* NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
* described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
*
* @return StubNumberFormatter
* @return NumberFormatter
*
* @see http://www.php.net/manual/en/numberformatter.create.php
* @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
@ -426,7 +426,7 @@ class StubNumberFormatter
*
* @see http://www.php.net/manual/en/numberformatter.getlocale.php
*/
public function getLocale($type = StubLocale::ACTUAL_LOCALE)
public function getLocale($type = Locale::ACTUAL_LOCALE)
{
return 'en';
}
@ -527,9 +527,9 @@ class StubNumberFormatter
// Any string before the numeric value causes error in the parsing
if (isset($matches[1]) && !empty($matches[1])) {
StubIntlGlobals::setError(StubIntlGlobals::U_PARSE_ERROR, 'Number parsing failed');
$this->errorCode = StubIntlGlobals::getErrorCode();
$this->errorMessage = StubIntlGlobals::getErrorMessage();
IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Number parsing failed');
$this->errorCode = IntlGlobals::getErrorCode();
$this->errorMessage = IntlGlobals::getErrorMessage();
return false;
}
@ -651,9 +651,9 @@ class StubNumberFormatter
*/
protected function resetError()
{
StubIntlGlobals::setError(StubIntlGlobals::U_ZERO_ERROR);
$this->errorCode = StubIntlGlobals::getErrorCode();
$this->errorMessage = StubIntlGlobals::getErrorMessage();
IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);
$this->errorCode = IntlGlobals::getErrorCode();
$this->errorMessage = IntlGlobals::getErrorMessage();
}
/**

View File

@ -9,15 +9,13 @@
* file that was distributed with this source code.
*/
use Symfony\Component\Intl\Collator\StubCollator;
/**
* Stub implementation for the Collator class of the intl extension
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see Symfony\Component\Intl\Collator\StubCollator
* @see \Symfony\Component\Intl\Collator\StubCollator
*/
class Collator extends StubCollator
class Collator extends \Symfony\Component\Intl\Collator\Collator
{
}

View File

@ -9,15 +9,13 @@
* file that was distributed with this source code.
*/
use Symfony\Component\Intl\DateFormatter\StubIntlDateFormatter;
/**
* Stub implementation for the IntlDateFormatter class of the intl extension
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see Symfony\Component\Intl\DateFormatter\StubIntlDateFormatter
* @see \Symfony\Component\Intl\DateFormatter\IntlDateFormatter
*/
class IntlDateFormatter extends StubIntlDateFormatter
class IntlDateFormatter extends \Symfony\Component\Intl\DateFormatter\IntlDateFormatter
{
}

View File

@ -9,15 +9,13 @@
* file that was distributed with this source code.
*/
use Symfony\Component\Intl\Locale\StubLocale;
/**
* Stub implementation for the Locale class of the intl extension
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see Symfony\Component\Intl\Locale\StubLocale
* @see \Symfony\Component\Intl\Locale\Locale
*/
class Locale extends StubLocale
class Locale extends \Symfony\Component\Intl\Locale\Locale
{
}

View File

@ -9,15 +9,13 @@
* file that was distributed with this source code.
*/
use Symfony\Component\Intl\NumberFormatter\StubNumberFormatter;
/**
* Stub implementation for the NumberFormatter class of the intl extension
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see Symfony\Component\Intl\NumberFormatter\StubNumberFormatter
* @see \Symfony\Component\Intl\NumberFormatter\NumberFormatter
*/
class NumberFormatter extends StubNumberFormatter
class NumberFormatter extends \Symfony\Component\Intl\NumberFormatter\NumberFormatter
{
}

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
use Symfony\Component\Intl\Globals\StubIntlGlobals;
use Symfony\Component\Intl\Globals\IntlGlobals;
if (!function_exists('intl_is_failure')) {
@ -27,7 +27,7 @@ if (!function_exists('intl_is_failure')) {
*/
function intl_is_failure($errorCode)
{
return StubIntlGlobals::isFailure($errorCode);
return IntlGlobals::isFailure($errorCode);
}
/**
@ -37,13 +37,13 @@ if (!function_exists('intl_is_failure')) {
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @return Boolean The error code of the last intl function call or
* StubIntlGlobals::U_ZERO_ERROR if no error occurred.
* IntlGlobals::U_ZERO_ERROR if no error occurred.
*
* @see \Symfony\Component\Intl\Globals\StubIntlGlobals::getErrorCode
*/
function intl_get_error_code()
{
return StubIntlGlobals::getErrorCode();
return IntlGlobals::getErrorCode();
}
/**
@ -59,7 +59,7 @@ if (!function_exists('intl_is_failure')) {
*/
function intl_get_error_message()
{
return StubIntlGlobals::getErrorMessage();
return IntlGlobals::getErrorMessage();
}
/**
@ -74,7 +74,7 @@ if (!function_exists('intl_is_failure')) {
*/
function intl_error_name($errorCode)
{
return StubIntlGlobals::getErrorName($errorCode);
return IntlGlobals::getErrorName($errorCode);
}
}

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\Intl\Tests\Collator;
use Symfony\Component\Intl\Collator\StubCollator;
use Symfony\Component\Intl\Collator\Collator;
use Symfony\Component\Intl\Locale;
/**
@ -37,17 +37,17 @@ abstract class AbstractCollatorTest extends \PHPUnit_Framework_TestCase
/* array, sortFlag, expected */
array(
array('a', 'b', 'c'),
StubCollator::SORT_REGULAR,
Collator::SORT_REGULAR,
array('a', 'b', 'c'),
),
array(
array('c', 'b', 'a'),
StubCollator::SORT_REGULAR,
Collator::SORT_REGULAR,
array(2 => 'a', 1 => 'b', 0 => 'c'),
),
array(
array('b', 'c', 'a'),
StubCollator::SORT_REGULAR,
Collator::SORT_REGULAR,
array(2 => 'a', 0 => 'b', 1 => 'c'),
),
);

View File

@ -11,17 +11,17 @@
namespace Symfony\Component\Intl\Tests\Collator;
use Symfony\Component\Intl\Collator\StubCollator;
use Symfony\Component\Intl\Globals\StubIntlGlobals;
use Symfony\Component\Intl\Collator\Collator;
use Symfony\Component\Intl\Globals\IntlGlobals;
class StubCollatorTest extends AbstractCollatorTest
class CollatorTest extends AbstractCollatorTest
{
/**
* @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
*/
public function testConstructorWithUnsupportedLocale()
{
new StubCollator('pt_BR');
new Collator('pt_BR');
}
/**
@ -39,13 +39,13 @@ class StubCollatorTest extends AbstractCollatorTest
public function testGetAttribute()
{
$collator = $this->getCollator('en');
$collator->getAttribute(StubCollator::NUMERIC_COLLATION);
$collator->getAttribute(Collator::NUMERIC_COLLATION);
}
public function testGetErrorCode()
{
$collator = $this->getCollator('en');
$this->assertEquals(StubIntlGlobals::U_ZERO_ERROR, $collator->getErrorCode());
$this->assertEquals(IntlGlobals::U_ZERO_ERROR, $collator->getErrorCode());
}
public function testGetErrorMessage()
@ -84,7 +84,7 @@ class StubCollatorTest extends AbstractCollatorTest
public function testSetAttribute()
{
$collator = $this->getCollator('en');
$collator->setAttribute(StubCollator::NUMERIC_COLLATION, StubCollator::ON);
$collator->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON);
}
/**
@ -93,17 +93,17 @@ class StubCollatorTest extends AbstractCollatorTest
public function testSetStrength()
{
$collator = $this->getCollator('en');
$collator->setStrength(StubCollator::PRIMARY);
$collator->setStrength(Collator::PRIMARY);
}
public function testStaticCreate()
{
$collator = StubCollator::create('en');
$this->assertInstanceOf('Symfony\Component\Intl\Collator\StubCollator', $collator);
$collator = Collator::create('en');
$this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
}
protected function getCollator($locale)
{
return new StubCollator($locale);
return new Collator($locale);
}
}

View File

@ -11,8 +11,8 @@
namespace Symfony\Component\Intl\Tests\DateFormatter;
use Symfony\Component\Intl\DateFormatter\StubIntlDateFormatter;
use Symfony\Component\Intl\Globals\StubIntlGlobals;
use Symfony\Component\Intl\DateFormatter\IntlDateFormatter;
use Symfony\Component\Intl\Globals\IntlGlobals;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Intl\Util\IcuVersion;
use Symfony\Component\Intl\Util\Version;
@ -32,7 +32,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testConstructorDefaultTimeZone()
{
$formatter = $this->getDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
// In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
@ -47,7 +47,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormat($pattern, $timestamp, $expected)
{
$errorCode = StubIntlGlobals::U_ZERO_ERROR;
$errorCode = IntlGlobals::U_ZERO_ERROR;
$errorMessage = 'U_ZERO_ERROR';
$formatter = $this->getDefaultDateFormatter($pattern);
@ -257,7 +257,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatIllegalArgumentError($pattern, $timestamp, $errorMessage)
{
$errorCode = StubIntlGlobals::U_ILLEGAL_ARGUMENT_ERROR;
$errorCode = IntlGlobals::U_ILLEGAL_ARGUMENT_ERROR;
$formatter = $this->getDefaultDateFormatter($pattern);
$this->assertFalse($formatter->format($timestamp));
@ -291,7 +291,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormatWithTimezone($timestamp, $timezone, $expected)
{
$pattern = 'yyyy-MM-dd HH:mm:ss';
$formatter = $this->getDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT, $timezone, StubIntlDateFormatter::GREGORIAN, $pattern);
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, $timezone, IntlDateFormatter::GREGORIAN, $pattern);
$this->assertSame($expected, $formatter->format($timestamp));
}
@ -375,7 +375,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormatWithConstructorTimezone()
{
$formatter = $this->getDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT, 'UTC');
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC');
$formatter->setPattern('yyyy-MM-dd HH:mm:ss');
$this->assertEquals(
@ -393,7 +393,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
$tz = getenv('TZ');
putenv('TZ=Europe/London');
$formatter = $this->getDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
$formatter->setPattern('yyyy-MM-dd HH:mm:ss');
$this->assertEquals(
@ -416,7 +416,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
$tz = date_default_timezone_get();
date_default_timezone_set('Europe/London');
$formatter = $this->getDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
$formatter->setPattern('yyyy-MM-dd HH:mm:ss');
$this->assertEquals(
@ -442,27 +442,27 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
public function dateAndTimeTypeProvider()
{
return array(
array(0, StubIntlDateFormatter::FULL, StubIntlDateFormatter::NONE, 'Thursday, January 1, 1970'),
array(0, StubIntlDateFormatter::LONG, StubIntlDateFormatter::NONE, 'January 1, 1970'),
array(0, StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::NONE, 'Jan 1, 1970'),
array(0, StubIntlDateFormatter::SHORT, StubIntlDateFormatter::NONE, '1/1/70'),
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::FULL, '12:00:00 AM GMT'),
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::LONG, '12:00:00 AM GMT'),
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::MEDIUM, '12:00:00 AM'),
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::SHORT, '12:00 AM'),
array(0, IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'Thursday, January 1, 1970'),
array(0, IntlDateFormatter::LONG, IntlDateFormatter::NONE, 'January 1, 1970'),
array(0, IntlDateFormatter::MEDIUM, IntlDateFormatter::NONE, 'Jan 1, 1970'),
array(0, IntlDateFormatter::SHORT, IntlDateFormatter::NONE, '1/1/70'),
array(0, IntlDateFormatter::NONE, IntlDateFormatter::FULL, '12:00:00 AM GMT'),
array(0, IntlDateFormatter::NONE, IntlDateFormatter::LONG, '12:00:00 AM GMT'),
array(0, IntlDateFormatter::NONE, IntlDateFormatter::MEDIUM, '12:00:00 AM'),
array(0, IntlDateFormatter::NONE, IntlDateFormatter::SHORT, '12:00 AM'),
);
}
public function testGetCalendar()
{
$formatter = $this->getDefaultDateFormatter();
$this->assertEquals(StubIntlDateFormatter::GREGORIAN, $formatter->getCalendar());
$this->assertEquals(IntlDateFormatter::GREGORIAN, $formatter->getCalendar());
}
public function testGetDateType()
{
$formatter = $this->getDateFormatter('en', StubIntlDateFormatter::FULL, StubIntlDateFormatter::NONE);
$this->assertEquals(StubIntlDateFormatter::FULL, $formatter->getDateType());
$formatter = $this->getDateFormatter('en', IntlDateFormatter::FULL, IntlDateFormatter::NONE);
$this->assertEquals(IntlDateFormatter::FULL, $formatter->getDateType());
}
public function testGetLocale()
@ -473,14 +473,14 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
public function testGetPattern()
{
$formatter = $this->getDateFormatter('en', StubIntlDateFormatter::FULL, StubIntlDateFormatter::NONE, 'UTC', StubIntlDateFormatter::GREGORIAN, 'yyyy-MM-dd');
$formatter = $this->getDateFormatter('en', IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'UTC', IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd');
$this->assertEquals('yyyy-MM-dd', $formatter->getPattern());
}
public function testGetTimeType()
{
$formatter = $this->getDateFormatter('en', StubIntlDateFormatter::NONE, StubIntlDateFormatter::FULL);
$this->assertEquals(StubIntlDateFormatter::FULL, $formatter->getTimeType());
$formatter = $this->getDateFormatter('en', IntlDateFormatter::NONE, IntlDateFormatter::FULL);
$this->assertEquals(IntlDateFormatter::FULL, $formatter->getTimeType());
}
/**
@ -488,7 +488,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testParse($pattern, $value, $expected)
{
$errorCode = StubIntlGlobals::U_ZERO_ERROR;
$errorCode = IntlGlobals::U_ZERO_ERROR;
$errorMessage = 'U_ZERO_ERROR';
$formatter = $this->getDefaultDateFormatter($pattern);
@ -787,7 +787,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testParseError($pattern, $value)
{
$errorCode = StubIntlGlobals::U_PARSE_ERROR;
$errorCode = IntlGlobals::U_PARSE_ERROR;
$errorMessage = 'Date parsing failed: U_PARSE_ERROR';
$formatter = $this->getDefaultDateFormatter($pattern);
@ -876,7 +876,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
protected function getDefaultDateFormatter($pattern = null)
{
return $this->getDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT, 'UTC', StubIntlDateFormatter::GREGORIAN, $pattern);
return $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, $pattern);
}
protected function getDateTime($timestamp = null)
@ -906,7 +906,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
protected function assertIsIntlSuccess($formatter, $errorMessage, $errorCode)
{
/* @var StubIntlDateFormatter $formatter */
/* @var IntlDateFormatter $formatter */
$this->assertSame($errorMessage, $this->getIntlErrorMessage());
$this->assertSame($errorCode, $this->getIntlErrorCode());
$this->assertFalse($this->isIntlFailure($this->getIntlErrorCode()));
@ -925,7 +925,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
*
* @return mixed
*/
abstract protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = StubIntlDateFormatter::GREGORIAN, $pattern = null);
abstract protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null);
/**
* @return string

View File

@ -11,15 +11,15 @@
namespace Symfony\Component\Intl\Tests\DateFormatter;
use Symfony\Component\Intl\DateFormatter\StubIntlDateFormatter;
use Symfony\Component\Intl\Globals\StubIntlGlobals;
use Symfony\Component\Intl\DateFormatter\IntlDateFormatter;
use Symfony\Component\Intl\Globals\IntlGlobals;
use Symfony\Component\Intl\Util\Version;
class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
{
public function testConstructor()
{
$formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT, 'UTC', StubIntlDateFormatter::GREGORIAN, 'y-M-d');
$formatter = new IntlDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, 'y-M-d');
$this->assertEquals('y-M-d', $formatter->getPattern());
}
@ -28,13 +28,13 @@ class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
*/
public function testConstructorWithUnsupportedLocale()
{
new StubIntlDateFormatter('pt_BR', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
new IntlDateFormatter('pt_BR', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
}
public function testStaticCreate()
{
$formatter = StubIntlDateFormatter::create('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
$this->assertInstanceOf('Symfony\Component\Intl\DateFormatter\StubIntlDateFormatter', $formatter);
$formatter = IntlDateFormatter::create('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
$this->assertInstanceOf('\Symfony\Component\Intl\DateFormatter\IntlDateFormatter', $formatter);
}
public function testFormatWithUnsupportedTimestampArgument()
@ -72,7 +72,7 @@ class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
public function testFormatWithUnimplementedChars()
{
$pattern = 'Y';
$formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT, 'UTC', StubIntlDateFormatter::GREGORIAN, $pattern);
$formatter = new IntlDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, $pattern);
$formatter->format(0);
}
@ -88,13 +88,13 @@ class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
public function testGetErrorCode()
{
$formatter = $this->getDefaultDateFormatter();
$this->assertEquals(StubIntlGlobals::getErrorCode(), $formatter->getErrorCode());
$this->assertEquals(IntlGlobals::getErrorCode(), $formatter->getErrorCode());
}
public function testGetErrorMessage()
{
$formatter = $this->getDefaultDateFormatter();
$this->assertEquals(StubIntlGlobals::getErrorMessage(), $formatter->getErrorMessage());
$this->assertEquals(IntlGlobals::getErrorMessage(), $formatter->getErrorMessage());
}
public function testIsLenient()
@ -128,7 +128,7 @@ class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
public function testSetCalendar()
{
$formatter = $this->getDefaultDateFormatter();
$formatter->setCalendar(StubIntlDateFormatter::GREGORIAN);
$formatter->setCalendar(IntlDateFormatter::GREGORIAN);
}
/**
@ -176,24 +176,24 @@ class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
return $this->notImplemented(parent::parseQuarterProvider());
}
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = StubIntlDateFormatter::GREGORIAN, $pattern = null)
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
{
return new StubIntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
return new IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
}
protected function getIntlErrorMessage()
{
return StubIntlGlobals::getErrorMessage();
return IntlGlobals::getErrorMessage();
}
protected function getIntlErrorCode()
{
return StubIntlGlobals::getErrorCode();
return IntlGlobals::getErrorCode();
}
protected function isIntlFailure($errorCode)
{
return StubIntlGlobals::isFailure($errorCode);
return IntlGlobals::isFailure($errorCode);
}
/**

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\Intl\Tests\DateFormatter\Verification;
use Symfony\Component\Intl\DateFormatter\StubIntlDateFormatter;
use Symfony\Component\Intl\DateFormatter\IntlDateFormatter;
use Symfony\Component\Intl\Tests\DateFormatter\AbstractIntlDateFormatterTest;
use Symfony\Component\Intl\Util\IntlTestHelper;
@ -42,7 +42,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
parent::testFormatWithTimezoneFromEnvironmentVariable();
}
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = StubIntlDateFormatter::GREGORIAN, $pattern = null)
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
{
return new \IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
}

View File

@ -11,12 +11,12 @@
namespace Symfony\Component\Intl\Tests\Globals;
use Symfony\Component\Intl\Globals\StubIntlGlobals;
use Symfony\Component\Intl\Globals\IntlGlobals;
class StubIntlGlobalsTest extends AbstractIntlGlobalsTest
class IntlGlobalsTest extends AbstractIntlGlobalsTest
{
protected function getIntlErrorName($errorCode)
{
return StubIntlGlobals::getErrorName($errorCode);
return IntlGlobals::getErrorName($errorCode);
}
}

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\Intl\Tests\Locale;
class StubLocaleTest extends AbstractLocaleTest
class LocaleTest extends AbstractLocaleTest
{
/**
* @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
@ -154,6 +154,6 @@ class StubLocaleTest extends AbstractLocaleTest
{
$args = array_slice(func_get_args(), 1);
return call_user_func_array(array('Symfony\Component\Intl\Locale\StubLocale', $methodName), $args);
return call_user_func_array(array('Symfony\Component\Intl\Locale\Locale', $methodName), $args);
}
}

View File

@ -11,10 +11,10 @@
namespace Symfony\Component\Intl\Tests\NumberFormatter;
use Symfony\Component\Intl\Globals\StubIntlGlobals;
use Symfony\Component\Intl\Globals\IntlGlobals;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Intl\Locale;
use Symfony\Component\Intl\NumberFormatter\StubNumberFormatter;
use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
use Symfony\Component\Intl\Util\IcuVersion;
use Symfony\Component\Intl\Util\IntlTestHelper;
@ -29,7 +29,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatCurrencyWithDecimalStyle($value, $currency, $expected)
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$this->assertEquals($expected, $formatter->formatCurrency($value, $currency));
}
@ -59,7 +59,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatCurrencyWithCurrencyStyle($value, $currency, $expected)
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
$formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
$this->assertEquals($expected, $formatter->formatCurrency($value, $currency));
}
@ -85,7 +85,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatCurrencyWithCurrencyStyleCostaRicanColonsRounding($value, $currency, $symbol, $expected)
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
$formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
$this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency));
}
@ -103,7 +103,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatCurrencyWithCurrencyStyleBrazilianRealRounding($value, $currency, $symbol, $expected)
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
$formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
$this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency));
}
@ -130,7 +130,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatCurrencyWithCurrencyStyleSwissRounding($value, $currency, $symbol, $expected)
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
$formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
$this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency));
}
@ -158,10 +158,10 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormat()
{
$errorCode = StubIntlGlobals::U_ZERO_ERROR;
$errorCode = IntlGlobals::U_ZERO_ERROR;
$errorMessage = 'U_ZERO_ERROR';
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$this->assertSame('9.555', $formatter->format(9.555));
$this->assertSame($errorMessage, $this->getIntlErrorMessage());
@ -174,7 +174,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormatWithCurrencyStyle()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
$formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
$this->assertEquals('¤1.00', $formatter->format(1));
}
@ -183,13 +183,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatTypeInt32($formatter, $value, $expected, $message = '')
{
$formattedValue = $formatter->format($value, StubNumberFormatter::TYPE_INT32);
$formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT32);
$this->assertEquals($expected, $formattedValue, $message);
}
public function formatTypeInt32Provider()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$message = '->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.';
@ -206,13 +206,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message = '')
{
$formattedValue = $formatter->format($value, StubNumberFormatter::TYPE_INT32);
$formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT32);
$this->assertEquals($expected, $formattedValue, $message);
}
public function formatTypeInt32WithCurrencyStyleProvider()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
$formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
$message = '->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.';
@ -230,13 +230,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatTypeInt64($formatter, $value, $expected)
{
$formattedValue = $formatter->format($value, StubNumberFormatter::TYPE_INT64);
$formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT64);
$this->assertEquals($expected, $formattedValue);
}
public function formatTypeInt64Provider()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
return array(
array($formatter, 1, '1'),
@ -251,13 +251,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected)
{
$formattedValue = $formatter->format($value, StubNumberFormatter::TYPE_INT64);
$formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT64);
$this->assertEquals($expected, $formattedValue);
}
public function formatTypeInt64WithCurrencyStyleProvider()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
$formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
return array(
array($formatter, 1, '¤1.00'),
@ -272,13 +272,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatTypeDouble($formatter, $value, $expected)
{
$formattedValue = $formatter->format($value, StubNumberFormatter::TYPE_DOUBLE);
$formattedValue = $formatter->format($value, NumberFormatter::TYPE_DOUBLE);
$this->assertEquals($expected, $formattedValue);
}
public function formatTypeDoubleProvider()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
return array(
array($formatter, 1, '1'),
@ -291,13 +291,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected)
{
$formattedValue = $formatter->format($value, StubNumberFormatter::TYPE_DOUBLE);
$formattedValue = $formatter->format($value, NumberFormatter::TYPE_DOUBLE);
$this->assertEquals($expected, $formattedValue);
}
public function formatTypeDoubleWithCurrencyStyleProvider()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
$formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
return array(
array($formatter, 1, '¤1.00'),
@ -311,7 +311,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatTypeCurrency($formatter, $value)
{
$formatter->format($value, StubNumberFormatter::TYPE_CURRENCY);
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
}
/**
@ -319,13 +319,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatTypeCurrencyReturn($formatter, $value)
{
$this->assertFalse(@$formatter->format($value, StubNumberFormatter::TYPE_CURRENCY));
$this->assertFalse(@$formatter->format($value, NumberFormatter::TYPE_CURRENCY));
}
public function formatTypeCurrencyProvider()
{
$df = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$cf = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
$df = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$cf = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
return array(
array($df, 1),
@ -338,15 +338,15 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatFractionDigits($value, $expected, $fractionDigits = null, $expectedFractionDigits = 1)
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
if (null !== $fractionDigits) {
$attributeRet = $formatter->setAttribute(StubNumberFormatter::FRACTION_DIGITS, $fractionDigits);
$attributeRet = $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $fractionDigits);
}
$formattedValue = $formatter->format($value);
$this->assertSame($expected, $formattedValue);
$this->assertSame($expectedFractionDigits, $formatter->getAttribute(StubNumberFormatter::FRACTION_DIGITS));
$this->assertSame($expectedFractionDigits, $formatter->getAttribute(NumberFormatter::FRACTION_DIGITS));
if (isset($attributeRet)) {
$this->assertTrue($attributeRet);
@ -370,15 +370,15 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatGroupingUsed($value, $expected, $groupingUsed = null, $expectedGroupingUsed = 1)
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
if (null !== $groupingUsed) {
$attributeRet = $formatter->setAttribute(StubNumberFormatter::GROUPING_USED, $groupingUsed);
$attributeRet = $formatter->setAttribute(NumberFormatter::GROUPING_USED, $groupingUsed);
}
$formattedValue = $formatter->format($value);
$this->assertSame($expected, $formattedValue);
$this->assertSame($expectedGroupingUsed, $formatter->getAttribute(StubNumberFormatter::GROUPING_USED));
$this->assertSame($expectedGroupingUsed, $formatter->getAttribute(NumberFormatter::GROUPING_USED));
if (isset($attributeRet)) {
$this->assertTrue($attributeRet);
@ -402,10 +402,10 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatRoundingModeHalfUp($value, $expected)
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter->setAttribute(StubNumberFormatter::FRACTION_DIGITS, 2);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2);
$formatter->setAttribute(StubNumberFormatter::ROUNDING_MODE, StubNumberFormatter::ROUND_HALFUP);
$formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFUP);
$this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFUP rounding mode.');
}
@ -426,10 +426,10 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatRoundingModeHalfDown($value, $expected)
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter->setAttribute(StubNumberFormatter::FRACTION_DIGITS, 2);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2);
$formatter->setAttribute(StubNumberFormatter::ROUNDING_MODE, StubNumberFormatter::ROUND_HALFDOWN);
$formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFDOWN);
$this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFDOWN rounding mode.');
}
@ -449,10 +449,10 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testFormatRoundingModeHalfEven($value, $expected)
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter->setAttribute(StubNumberFormatter::FRACTION_DIGITS, 2);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2);
$formatter->setAttribute(StubNumberFormatter::ROUNDING_MODE, StubNumberFormatter::ROUND_HALFEVEN);
$formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFEVEN);
$this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFEVEN rounding mode.');
}
@ -469,7 +469,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
public function testGetLocale()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$this->assertEquals('en', $formatter->getLocale());
}
@ -478,15 +478,15 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testParse($value, $expected, $message = '')
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$parsedValue = $formatter->parse($value, StubNumberFormatter::TYPE_DOUBLE);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE);
$this->assertSame($expected, $parsedValue, $message);
if ($expected === false) {
$errorCode = StubIntlGlobals::U_PARSE_ERROR;
$errorCode = IntlGlobals::U_PARSE_ERROR;
$errorMessage = 'Number parsing failed: U_PARSE_ERROR';
} else {
$errorCode = StubIntlGlobals::U_ZERO_ERROR;
$errorCode = IntlGlobals::U_ZERO_ERROR;
$errorMessage = 'U_ZERO_ERROR';
}
@ -511,8 +511,8 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testParseTypeDefault()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter->parse('1', StubNumberFormatter::TYPE_DEFAULT);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
}
/**
@ -520,8 +520,8 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testParseTypeInt32($value, $expected, $message = '')
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$parsedValue = $formatter->parse($value, StubNumberFormatter::TYPE_INT32);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$parsedValue = $formatter->parse($value, NumberFormatter::TYPE_INT32);
$this->assertSame($expected, $parsedValue);
}
@ -541,13 +541,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
{
IntlTestHelper::require32Bit($this);
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$parsedValue = $formatter->parse('2,147,483,647', StubNumberFormatter::TYPE_INT64);
$parsedValue = $formatter->parse('2,147,483,647', NumberFormatter::TYPE_INT64);
$this->assertInternalType('integer', $parsedValue);
$this->assertEquals(2147483647, $parsedValue);
$parsedValue = $formatter->parse('-2,147,483,648', StubNumberFormatter::TYPE_INT64);
$parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter::TYPE_INT64);
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
// The negative PHP_INT_MAX was being converted to float
@ -567,13 +567,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
{
IntlTestHelper::require64Bit($this);
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$parsedValue = $formatter->parse('2,147,483,647', StubNumberFormatter::TYPE_INT64);
$parsedValue = $formatter->parse('2,147,483,647', NumberFormatter::TYPE_INT64);
$this->assertInternalType('integer', $parsedValue);
$this->assertEquals(2147483647, $parsedValue);
$parsedValue = $formatter->parse('-2,147,483,648', StubNumberFormatter::TYPE_INT64);
$parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter::TYPE_INT64);
$this->assertInternalType('integer', $parsedValue);
$this->assertEquals(-2147483647 - 1, $parsedValue);
}
@ -585,14 +585,14 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
{
IntlTestHelper::require32Bit($this);
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
// int 64 using only 32 bit range strangeness
$parsedValue = $formatter->parse('2,147,483,648', StubNumberFormatter::TYPE_INT64);
$parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64);
$this->assertInternalType('float', $parsedValue);
$this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range.');
$parsedValue = $formatter->parse('-2,147,483,649', StubNumberFormatter::TYPE_INT64);
$parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter::TYPE_INT64);
$this->assertInternalType('float', $parsedValue);
$this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range.');
}
@ -604,9 +604,9 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
{
IntlTestHelper::require64Bit($this);
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$parsedValue = $formatter->parse('2,147,483,648', StubNumberFormatter::TYPE_INT64);
$parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64);
$this->assertInternalType('integer', $parsedValue);
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
@ -620,7 +620,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).');
}
$parsedValue = $formatter->parse('-2,147,483,649', StubNumberFormatter::TYPE_INT64);
$parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter::TYPE_INT64);
$this->assertInternalType('integer', $parsedValue);
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
@ -640,8 +640,8 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testParseTypeDouble($value, $expectedValue)
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$parsedValue = $formatter->parse($value, StubNumberFormatter::TYPE_DOUBLE);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE);
$this->assertSame($expectedValue, $parsedValue);
}
@ -660,23 +660,23 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
*/
public function testParseTypeCurrency()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter->parse('1', StubNumberFormatter::TYPE_CURRENCY);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);
}
public function testParseWithNullPositionValue()
{
$position = null;
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter->parse('123', StubNumberFormatter::TYPE_INT32, $position);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->parse('123', NumberFormatter::TYPE_INT32, $position);
$this->assertNull($position);
}
public function testParseWithNotNullPositionValue()
{
$position = 1;
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter->parse('123', StubNumberFormatter::TYPE_DOUBLE, $position);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->parse('123', NumberFormatter::TYPE_DOUBLE, $position);
$this->assertEquals(3, $position);
}

View File

@ -11,15 +11,15 @@
namespace Symfony\Component\Intl\Tests\NumberFormatter;
use Symfony\Component\Intl\Globals\StubIntlGlobals;
use Symfony\Component\Intl\NumberFormatter\StubNumberFormatter;
use Symfony\Component\Intl\Globals\IntlGlobals;
use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
use Symfony\Component\Intl\Util\IntlTestHelper;
/**
* Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known
* behavior of PHP.
*/
class StubNumberFormatterTest extends AbstractNumberFormatterTest
class NumberFormatterTest extends AbstractNumberFormatterTest
{
protected function setUp()
{
@ -33,7 +33,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testConstructorWithUnsupportedLocale()
{
new StubNumberFormatter('pt_BR');
new NumberFormatter('pt_BR');
}
/**
@ -41,7 +41,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testConstructorWithUnsupportedStyle()
{
new StubNumberFormatter('en', StubNumberFormatter::PATTERN_DECIMAL);
new NumberFormatter('en', NumberFormatter::PATTERN_DECIMAL);
}
/**
@ -49,7 +49,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testConstructorWithPatternDifferentThanNull()
{
new StubNumberFormatter('en', StubNumberFormatter::DECIMAL, '');
new NumberFormatter('en', NumberFormatter::DECIMAL, '');
}
/**
@ -57,8 +57,8 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testSetAttributeWithUnsupportedAttribute()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter->setAttribute(StubNumberFormatter::LENIENT_PARSE, null);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setAttribute(NumberFormatter::LENIENT_PARSE, null);
}
/**
@ -66,15 +66,15 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testSetAttributeInvalidRoundingMode()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter->setAttribute(StubNumberFormatter::ROUNDING_MODE, null);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setAttribute(NumberFormatter::ROUNDING_MODE, null);
}
public function testCreate()
{
$this->assertInstanceOf(
'Symfony\Component\Intl\NumberFormatter\StubNumberFormatter',
StubNumberFormatter::create('en', StubNumberFormatter::DECIMAL)
'\Symfony\Component\Intl\NumberFormatter\NumberFormatter',
NumberFormatter::create('en', NumberFormatter::DECIMAL)
);
}
@ -145,7 +145,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testGetPattern()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->getPattern();
}
@ -154,7 +154,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testGetSymbol()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->getSymbol(null);
}
@ -163,14 +163,14 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testGetTextAttribute()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->getTextAttribute(null);
}
public function testGetErrorCode()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$this->assertEquals(StubIntlGlobals::U_ZERO_ERROR, $formatter->getErrorCode());
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$this->assertEquals(IntlGlobals::U_ZERO_ERROR, $formatter->getErrorCode());
}
/**
@ -178,7 +178,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testParseCurrency()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->parseCurrency(null, $currency);
}
@ -195,7 +195,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testSetPattern()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setPattern(null);
}
@ -204,7 +204,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testSetSymbol()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setSymbol(null, null);
}
@ -213,27 +213,27 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
*/
public function testSetTextAttribute()
{
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setTextAttribute(null, null);
}
protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null)
{
return new StubNumberFormatter($locale, $style, $pattern);
return new NumberFormatter($locale, $style, $pattern);
}
protected function getIntlErrorMessage()
{
return StubIntlGlobals::getErrorMessage();
return IntlGlobals::getErrorMessage();
}
protected function getIntlErrorCode()
{
return StubIntlGlobals::getErrorCode();
return IntlGlobals::getErrorCode();
}
protected function isIntlFailure($errorCode)
{
return StubIntlGlobals::isFailure($errorCode);
return IntlGlobals::isFailure($errorCode);
}
}