[Intl] Removed "Stub" prefix from stub classes
This commit is contained in:
parent
60f31d1004
commit
b4cccfd9b6
@ -13,8 +13,8 @@ namespace Symfony\Component\Intl\Collator;
|
|||||||
|
|
||||||
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
|
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
|
||||||
use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
|
use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
|
||||||
use Symfony\Component\Intl\Globals\StubIntlGlobals;
|
use Symfony\Component\Intl\Globals\IntlGlobals;
|
||||||
use Symfony\Component\Intl\Locale\StubLocale;
|
use Symfony\Component\Intl\Locale\Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement for PHP's native {@link \Collator} class.
|
* 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 Igor Wiedler <igor@wiedler.ch>
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
class StubCollator
|
class Collator
|
||||||
{
|
{
|
||||||
/* Attribute constants */
|
/* Attribute constants */
|
||||||
const FRENCH_COLLATION = 0;
|
const FRENCH_COLLATION = 0;
|
||||||
@ -86,7 +86,7 @@ class StubCollator
|
|||||||
*
|
*
|
||||||
* @param string $locale The locale code. The only currently supported locale is "en".
|
* @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
|
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed
|
||||||
*/
|
*/
|
||||||
@ -100,9 +100,9 @@ class StubCollator
|
|||||||
*
|
*
|
||||||
* @param array &$array Input array
|
* @param array &$array Input array
|
||||||
* @param integer $sortFlag Flags for sorting, can be one of the following:
|
* @param integer $sortFlag Flags for sorting, can be one of the following:
|
||||||
* StubCollator::SORT_REGULAR - compare items normally (don't change types)
|
* Collator::SORT_REGULAR - compare items normally (don't change types)
|
||||||
* StubCollator::SORT_NUMERIC - compare items numerically
|
* Collator::SORT_NUMERIC - compare items numerically
|
||||||
* StubCollator::SORT_STRING - compare items as strings
|
* Collator::SORT_STRING - compare items as strings
|
||||||
*
|
*
|
||||||
* @return Boolean True on success or false on failure
|
* @return Boolean True on success or false on failure
|
||||||
*/
|
*/
|
||||||
@ -162,7 +162,7 @@ class StubCollator
|
|||||||
*/
|
*/
|
||||||
public function getErrorCode()
|
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
|
* @return string The locale used to create the collator. Currently always
|
||||||
* returns "en".
|
* returns "en".
|
||||||
*/
|
*/
|
||||||
public function getLocale($type = StubLocale::ACTUAL_LOCALE)
|
public function getLocale($type = Locale::ACTUAL_LOCALE)
|
||||||
{
|
{
|
||||||
return 'en';
|
return 'en';
|
||||||
}
|
}
|
||||||
@ -239,12 +239,12 @@ class StubCollator
|
|||||||
* Not supported. Set the collator's strength
|
* Not supported. Set the collator's strength
|
||||||
*
|
*
|
||||||
* @param int $strength Strength to set, possible values:
|
* @param int $strength Strength to set, possible values:
|
||||||
* StubCollator::PRIMARY
|
* Collator::PRIMARY
|
||||||
* StubCollator::SECONDARY
|
* Collator::SECONDARY
|
||||||
* StubCollator::TERTIARY
|
* Collator::TERTIARY
|
||||||
* StubCollator::QUATERNARY
|
* Collator::QUATERNARY
|
||||||
* StubCollator::IDENTICAL
|
* Collator::IDENTICAL
|
||||||
* StubCollator::DEFAULT
|
* Collator::DEFAULT
|
||||||
*
|
*
|
||||||
* @return Boolean True on success or false on failure
|
* @return Boolean True on success or false on failure
|
||||||
*
|
*
|
||||||
@ -278,9 +278,9 @@ class StubCollator
|
|||||||
*
|
*
|
||||||
* @param array &$arr Array of string to sort
|
* @param array &$arr Array of string to sort
|
||||||
* @param int $sortFlag Optional sorting type, one of the following:
|
* @param int $sortFlag Optional sorting type, one of the following:
|
||||||
* StubCollator::SORT_REGULAR
|
* Collator::SORT_REGULAR
|
||||||
* StubCollator::SORT_NUMERIC
|
* Collator::SORT_NUMERIC
|
||||||
* StubCollator::SORT_STRING
|
* Collator::SORT_STRING
|
||||||
*
|
*
|
||||||
* @return Boolean True on success or false on failure
|
* @return Boolean True on success or false on failure
|
||||||
*
|
*
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\Intl\DateFormatter\DateFormat;
|
namespace Symfony\Component\Intl\DateFormatter\DateFormat;
|
||||||
|
|
||||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
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;
|
use Symfony\Component\Intl\DateFormatter\DateFormat\MonthTransformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,13 +156,13 @@ class FullTransformer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reset error code and message
|
// reset error code and message
|
||||||
StubIntlGlobals::setError(StubIntlGlobals::U_ZERO_ERROR);
|
IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);
|
||||||
|
|
||||||
return $this->calculateUnixTimestamp($dateTime, $options);
|
return $this->calculateUnixTimestamp($dateTime, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// behave like the intl extension
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
@ -303,7 +303,7 @@ class FullTransformer
|
|||||||
|
|
||||||
// If month is false, return immediately (intl behavior)
|
// If month is false, return immediately (intl behavior)
|
||||||
if (false === $month) {
|
if (false === $month) {
|
||||||
StubIntlGlobals::setError(StubIntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
|
IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\DateFormatter;
|
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\DateFormatter\DateFormat\FullTransformer;
|
||||||
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
|
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
|
||||||
use Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException;
|
use Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException;
|
||||||
use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
|
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.
|
* 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 Igor Wiedler <igor@wiedler.ch>
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
class StubIntlDateFormatter
|
class IntlDateFormatter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The error code from the last operation
|
* The error code from the last operation
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
protected $errorCode = StubIntlGlobals::U_ZERO_ERROR;
|
protected $errorCode = IntlGlobals::U_ZERO_ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The error message from the last operation
|
* The error message from the last operation
|
||||||
@ -171,7 +171,7 @@ class StubIntlDateFormatter
|
|||||||
* One of the calendar constants.
|
* One of the calendar constants.
|
||||||
* @param string $pattern Optional pattern to use when formatting
|
* @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://www.php.net/manual/en/intldateformatter.create.php
|
||||||
* @see http://userguide.icu-project.org/formatparse/datetime
|
* @see http://userguide.icu-project.org/formatparse/datetime
|
||||||
@ -219,9 +219,9 @@ class StubIntlDateFormatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $argumentError) {
|
if (null !== $argumentError) {
|
||||||
StubIntlGlobals::setError(StubIntlGlobals::U_ILLEGAL_ARGUMENT_ERROR, $argumentError);
|
IntlGlobals::setError(IntlGlobals::U_ILLEGAL_ARGUMENT_ERROR, $argumentError);
|
||||||
$this->errorCode = StubIntlGlobals::getErrorCode();
|
$this->errorCode = IntlGlobals::getErrorCode();
|
||||||
$this->errorMessage = StubIntlGlobals::getErrorMessage();
|
$this->errorMessage = IntlGlobals::getErrorMessage();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -235,9 +235,9 @@ class StubIntlDateFormatter
|
|||||||
$formatted = $transformer->format($this->createDateTime($timestamp));
|
$formatted = $transformer->format($this->createDateTime($timestamp));
|
||||||
|
|
||||||
// behave like the intl extension
|
// behave like the intl extension
|
||||||
StubIntlGlobals::setError(StubIntlGlobals::U_ZERO_ERROR);
|
IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);
|
||||||
$this->errorCode = StubIntlGlobals::getErrorCode();
|
$this->errorCode = IntlGlobals::getErrorCode();
|
||||||
$this->errorMessage = StubIntlGlobals::getErrorMessage();
|
$this->errorMessage = IntlGlobals::getErrorMessage();
|
||||||
|
|
||||||
return $formatted;
|
return $formatted;
|
||||||
}
|
}
|
||||||
@ -333,7 +333,7 @@ class StubIntlDateFormatter
|
|||||||
*
|
*
|
||||||
* @see http://www.php.net/manual/en/intldateformatter.getlocale.php
|
* @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';
|
return 'en';
|
||||||
}
|
}
|
||||||
@ -459,8 +459,8 @@ class StubIntlDateFormatter
|
|||||||
$timestamp = $transformer->parse($dateTime, $value);
|
$timestamp = $transformer->parse($dateTime, $value);
|
||||||
|
|
||||||
// behave like the intl extension. FullTransformer::parse() set the proper error
|
// behave like the intl extension. FullTransformer::parse() set the proper error
|
||||||
$this->errorCode = StubIntlGlobals::getErrorCode();
|
$this->errorCode = IntlGlobals::getErrorCode();
|
||||||
$this->errorMessage = StubIntlGlobals::getErrorMessage();
|
$this->errorMessage = IntlGlobals::getErrorMessage();
|
||||||
|
|
||||||
return $timestamp;
|
return $timestamp;
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ namespace Symfony\Component\Intl\Globals;
|
|||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
abstract class StubIntlGlobals
|
abstract class IntlGlobals
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Indicates that no error occurred
|
* Indicates that no error occurred
|
||||||
@ -67,7 +67,7 @@ abstract class StubIntlGlobals
|
|||||||
/**
|
/**
|
||||||
* Returns whether the error code indicates a failure
|
* 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
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
@ -80,7 +80,7 @@ abstract class StubIntlGlobals
|
|||||||
/**
|
/**
|
||||||
* Returns the error code of the last operation
|
* 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
|
* @return integer
|
||||||
*/
|
*/
|
||||||
@ -104,7 +104,7 @@ abstract class StubIntlGlobals
|
|||||||
/**
|
/**
|
||||||
* Returns the symbolic name for a given error code
|
* 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
|
* @return string
|
||||||
*/
|
*/
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\Locale;
|
namespace Symfony\Component\Intl\Locale;
|
||||||
|
|
||||||
use Symfony\Component\Intl\Locale;
|
|
||||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||||
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
|
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 Eriksen Costa <eriksen.costa@infranology.com.br>
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
class StubLocale
|
class Locale
|
||||||
{
|
{
|
||||||
const DEFAULT_LOCALE = null;
|
const DEFAULT_LOCALE = null;
|
||||||
|
|
@ -15,9 +15,9 @@ use Symfony\Component\Intl\Exception\NotImplementedException;
|
|||||||
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
|
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
|
||||||
use Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException;
|
use Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException;
|
||||||
use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
|
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\Intl;
|
||||||
use Symfony\Component\Intl\Locale\StubLocale;
|
use Symfony\Component\Intl\Locale\Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement for PHP's native {@link \NumberFormatter} class.
|
* 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 Eriksen Costa <eriksen.costa@infranology.com.br>
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
class StubNumberFormatter
|
class NumberFormatter
|
||||||
{
|
{
|
||||||
/* Format style constants */
|
/* Format style constants */
|
||||||
const PATTERN_DECIMAL = 0;
|
const PATTERN_DECIMAL = 0;
|
||||||
@ -132,7 +132,7 @@ class StubNumberFormatter
|
|||||||
*
|
*
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
protected $errorCode = StubIntlGlobals::U_ZERO_ERROR;
|
protected $errorCode = IntlGlobals::U_ZERO_ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The error message from the last operation
|
* The error message from the last operation
|
||||||
@ -187,8 +187,8 @@ class StubNumberFormatter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The available rounding modes for setAttribute() usage with
|
* The available rounding modes for setAttribute() usage with
|
||||||
* StubNumberFormatter::ROUNDING_MODE. StubNumberFormatter::ROUND_DOWN
|
* NumberFormatter::ROUNDING_MODE. NumberFormatter::ROUND_DOWN
|
||||||
* and StubNumberFormatter::ROUND_UP does not have a PHP only equivalent
|
* and NumberFormatter::ROUND_UP does not have a PHP only equivalent
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@ -280,7 +280,7 @@ class StubNumberFormatter
|
|||||||
* NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
|
* NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
|
||||||
* described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
|
* 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.php.net/manual/en/numberformatter.create.php
|
||||||
* @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
|
* @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
|
* @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';
|
return 'en';
|
||||||
}
|
}
|
||||||
@ -527,9 +527,9 @@ class StubNumberFormatter
|
|||||||
|
|
||||||
// Any string before the numeric value causes error in the parsing
|
// Any string before the numeric value causes error in the parsing
|
||||||
if (isset($matches[1]) && !empty($matches[1])) {
|
if (isset($matches[1]) && !empty($matches[1])) {
|
||||||
StubIntlGlobals::setError(StubIntlGlobals::U_PARSE_ERROR, 'Number parsing failed');
|
IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Number parsing failed');
|
||||||
$this->errorCode = StubIntlGlobals::getErrorCode();
|
$this->errorCode = IntlGlobals::getErrorCode();
|
||||||
$this->errorMessage = StubIntlGlobals::getErrorMessage();
|
$this->errorMessage = IntlGlobals::getErrorMessage();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -651,9 +651,9 @@ class StubNumberFormatter
|
|||||||
*/
|
*/
|
||||||
protected function resetError()
|
protected function resetError()
|
||||||
{
|
{
|
||||||
StubIntlGlobals::setError(StubIntlGlobals::U_ZERO_ERROR);
|
IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);
|
||||||
$this->errorCode = StubIntlGlobals::getErrorCode();
|
$this->errorCode = IntlGlobals::getErrorCode();
|
||||||
$this->errorMessage = StubIntlGlobals::getErrorMessage();
|
$this->errorMessage = IntlGlobals::getErrorMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -9,15 +9,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Symfony\Component\Intl\Collator\StubCollator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stub implementation for the Collator class of the intl extension
|
* Stub implementation for the Collator class of the intl extension
|
||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @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
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Symfony\Component\Intl\DateFormatter\StubIntlDateFormatter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stub implementation for the IntlDateFormatter class of the intl extension
|
* Stub implementation for the IntlDateFormatter class of the intl extension
|
||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @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
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Symfony\Component\Intl\Locale\StubLocale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stub implementation for the Locale class of the intl extension
|
* Stub implementation for the Locale class of the intl extension
|
||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @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
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,13 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Symfony\Component\Intl\NumberFormatter\StubNumberFormatter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stub implementation for the NumberFormatter class of the intl extension
|
* Stub implementation for the NumberFormatter class of the intl extension
|
||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @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
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* file that was distributed with this source code.
|
* 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')) {
|
if (!function_exists('intl_is_failure')) {
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ if (!function_exists('intl_is_failure')) {
|
|||||||
*/
|
*/
|
||||||
function intl_is_failure($errorCode)
|
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>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*
|
*
|
||||||
* @return Boolean The error code of the last intl function call or
|
* @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
|
* @see \Symfony\Component\Intl\Globals\StubIntlGlobals::getErrorCode
|
||||||
*/
|
*/
|
||||||
function intl_get_error_code()
|
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()
|
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)
|
function intl_error_name($errorCode)
|
||||||
{
|
{
|
||||||
return StubIntlGlobals::getErrorName($errorCode);
|
return IntlGlobals::getErrorName($errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\Tests\Collator;
|
namespace Symfony\Component\Intl\Tests\Collator;
|
||||||
|
|
||||||
use Symfony\Component\Intl\Collator\StubCollator;
|
use Symfony\Component\Intl\Collator\Collator;
|
||||||
use Symfony\Component\Intl\Locale;
|
use Symfony\Component\Intl\Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,17 +37,17 @@ abstract class AbstractCollatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
/* array, sortFlag, expected */
|
/* array, sortFlag, expected */
|
||||||
array(
|
array(
|
||||||
array('a', 'b', 'c'),
|
array('a', 'b', 'c'),
|
||||||
StubCollator::SORT_REGULAR,
|
Collator::SORT_REGULAR,
|
||||||
array('a', 'b', 'c'),
|
array('a', 'b', 'c'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('c', 'b', 'a'),
|
array('c', 'b', 'a'),
|
||||||
StubCollator::SORT_REGULAR,
|
Collator::SORT_REGULAR,
|
||||||
array(2 => 'a', 1 => 'b', 0 => 'c'),
|
array(2 => 'a', 1 => 'b', 0 => 'c'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('b', 'c', 'a'),
|
array('b', 'c', 'a'),
|
||||||
StubCollator::SORT_REGULAR,
|
Collator::SORT_REGULAR,
|
||||||
array(2 => 'a', 0 => 'b', 1 => 'c'),
|
array(2 => 'a', 0 => 'b', 1 => 'c'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -11,17 +11,17 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\Tests\Collator;
|
namespace Symfony\Component\Intl\Tests\Collator;
|
||||||
|
|
||||||
use Symfony\Component\Intl\Collator\StubCollator;
|
use Symfony\Component\Intl\Collator\Collator;
|
||||||
use Symfony\Component\Intl\Globals\StubIntlGlobals;
|
use Symfony\Component\Intl\Globals\IntlGlobals;
|
||||||
|
|
||||||
class StubCollatorTest extends AbstractCollatorTest
|
class CollatorTest extends AbstractCollatorTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
|
* @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
|
||||||
*/
|
*/
|
||||||
public function testConstructorWithUnsupportedLocale()
|
public function testConstructorWithUnsupportedLocale()
|
||||||
{
|
{
|
||||||
new StubCollator('pt_BR');
|
new Collator('pt_BR');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,13 +39,13 @@ class StubCollatorTest extends AbstractCollatorTest
|
|||||||
public function testGetAttribute()
|
public function testGetAttribute()
|
||||||
{
|
{
|
||||||
$collator = $this->getCollator('en');
|
$collator = $this->getCollator('en');
|
||||||
$collator->getAttribute(StubCollator::NUMERIC_COLLATION);
|
$collator->getAttribute(Collator::NUMERIC_COLLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetErrorCode()
|
public function testGetErrorCode()
|
||||||
{
|
{
|
||||||
$collator = $this->getCollator('en');
|
$collator = $this->getCollator('en');
|
||||||
$this->assertEquals(StubIntlGlobals::U_ZERO_ERROR, $collator->getErrorCode());
|
$this->assertEquals(IntlGlobals::U_ZERO_ERROR, $collator->getErrorCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetErrorMessage()
|
public function testGetErrorMessage()
|
||||||
@ -84,7 +84,7 @@ class StubCollatorTest extends AbstractCollatorTest
|
|||||||
public function testSetAttribute()
|
public function testSetAttribute()
|
||||||
{
|
{
|
||||||
$collator = $this->getCollator('en');
|
$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()
|
public function testSetStrength()
|
||||||
{
|
{
|
||||||
$collator = $this->getCollator('en');
|
$collator = $this->getCollator('en');
|
||||||
$collator->setStrength(StubCollator::PRIMARY);
|
$collator->setStrength(Collator::PRIMARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStaticCreate()
|
public function testStaticCreate()
|
||||||
{
|
{
|
||||||
$collator = StubCollator::create('en');
|
$collator = Collator::create('en');
|
||||||
$this->assertInstanceOf('Symfony\Component\Intl\Collator\StubCollator', $collator);
|
$this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getCollator($locale)
|
protected function getCollator($locale)
|
||||||
{
|
{
|
||||||
return new StubCollator($locale);
|
return new Collator($locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\Tests\DateFormatter;
|
namespace Symfony\Component\Intl\Tests\DateFormatter;
|
||||||
|
|
||||||
use Symfony\Component\Intl\DateFormatter\StubIntlDateFormatter;
|
use Symfony\Component\Intl\DateFormatter\IntlDateFormatter;
|
||||||
use Symfony\Component\Intl\Globals\StubIntlGlobals;
|
use Symfony\Component\Intl\Globals\IntlGlobals;
|
||||||
use Symfony\Component\Intl\Intl;
|
use Symfony\Component\Intl\Intl;
|
||||||
use Symfony\Component\Intl\Util\IcuVersion;
|
use Symfony\Component\Intl\Util\IcuVersion;
|
||||||
use Symfony\Component\Intl\Util\Version;
|
use Symfony\Component\Intl\Util\Version;
|
||||||
@ -32,7 +32,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testConstructorDefaultTimeZone()
|
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
|
// In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
|
||||||
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
|
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)
|
public function testFormat($pattern, $timestamp, $expected)
|
||||||
{
|
{
|
||||||
$errorCode = StubIntlGlobals::U_ZERO_ERROR;
|
$errorCode = IntlGlobals::U_ZERO_ERROR;
|
||||||
$errorMessage = 'U_ZERO_ERROR';
|
$errorMessage = 'U_ZERO_ERROR';
|
||||||
|
|
||||||
$formatter = $this->getDefaultDateFormatter($pattern);
|
$formatter = $this->getDefaultDateFormatter($pattern);
|
||||||
@ -257,7 +257,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatIllegalArgumentError($pattern, $timestamp, $errorMessage)
|
public function testFormatIllegalArgumentError($pattern, $timestamp, $errorMessage)
|
||||||
{
|
{
|
||||||
$errorCode = StubIntlGlobals::U_ILLEGAL_ARGUMENT_ERROR;
|
$errorCode = IntlGlobals::U_ILLEGAL_ARGUMENT_ERROR;
|
||||||
|
|
||||||
$formatter = $this->getDefaultDateFormatter($pattern);
|
$formatter = $this->getDefaultDateFormatter($pattern);
|
||||||
$this->assertFalse($formatter->format($timestamp));
|
$this->assertFalse($formatter->format($timestamp));
|
||||||
@ -291,7 +291,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testFormatWithTimezone($timestamp, $timezone, $expected)
|
public function testFormatWithTimezone($timestamp, $timezone, $expected)
|
||||||
{
|
{
|
||||||
$pattern = 'yyyy-MM-dd HH:mm:ss';
|
$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));
|
$this->assertSame($expected, $formatter->format($timestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testFormatWithConstructorTimezone()
|
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');
|
$formatter->setPattern('yyyy-MM-dd HH:mm:ss');
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -393,7 +393,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
$tz = getenv('TZ');
|
$tz = getenv('TZ');
|
||||||
putenv('TZ=Europe/London');
|
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');
|
$formatter->setPattern('yyyy-MM-dd HH:mm:ss');
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -416,7 +416,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
$tz = date_default_timezone_get();
|
$tz = date_default_timezone_get();
|
||||||
date_default_timezone_set('Europe/London');
|
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');
|
$formatter->setPattern('yyyy-MM-dd HH:mm:ss');
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -442,27 +442,27 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function dateAndTimeTypeProvider()
|
public function dateAndTimeTypeProvider()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(0, StubIntlDateFormatter::FULL, StubIntlDateFormatter::NONE, 'Thursday, January 1, 1970'),
|
array(0, IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'Thursday, January 1, 1970'),
|
||||||
array(0, StubIntlDateFormatter::LONG, StubIntlDateFormatter::NONE, 'January 1, 1970'),
|
array(0, IntlDateFormatter::LONG, IntlDateFormatter::NONE, 'January 1, 1970'),
|
||||||
array(0, StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::NONE, 'Jan 1, 1970'),
|
array(0, IntlDateFormatter::MEDIUM, IntlDateFormatter::NONE, 'Jan 1, 1970'),
|
||||||
array(0, StubIntlDateFormatter::SHORT, StubIntlDateFormatter::NONE, '1/1/70'),
|
array(0, IntlDateFormatter::SHORT, IntlDateFormatter::NONE, '1/1/70'),
|
||||||
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::FULL, '12:00:00 AM GMT'),
|
array(0, IntlDateFormatter::NONE, IntlDateFormatter::FULL, '12:00:00 AM GMT'),
|
||||||
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::LONG, '12:00:00 AM GMT'),
|
array(0, IntlDateFormatter::NONE, IntlDateFormatter::LONG, '12:00:00 AM GMT'),
|
||||||
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::MEDIUM, '12:00:00 AM'),
|
array(0, IntlDateFormatter::NONE, IntlDateFormatter::MEDIUM, '12:00:00 AM'),
|
||||||
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::SHORT, '12:00 AM'),
|
array(0, IntlDateFormatter::NONE, IntlDateFormatter::SHORT, '12:00 AM'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetCalendar()
|
public function testGetCalendar()
|
||||||
{
|
{
|
||||||
$formatter = $this->getDefaultDateFormatter();
|
$formatter = $this->getDefaultDateFormatter();
|
||||||
$this->assertEquals(StubIntlDateFormatter::GREGORIAN, $formatter->getCalendar());
|
$this->assertEquals(IntlDateFormatter::GREGORIAN, $formatter->getCalendar());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetDateType()
|
public function testGetDateType()
|
||||||
{
|
{
|
||||||
$formatter = $this->getDateFormatter('en', StubIntlDateFormatter::FULL, StubIntlDateFormatter::NONE);
|
$formatter = $this->getDateFormatter('en', IntlDateFormatter::FULL, IntlDateFormatter::NONE);
|
||||||
$this->assertEquals(StubIntlDateFormatter::FULL, $formatter->getDateType());
|
$this->assertEquals(IntlDateFormatter::FULL, $formatter->getDateType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetLocale()
|
public function testGetLocale()
|
||||||
@ -473,14 +473,14 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetPattern()
|
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());
|
$this->assertEquals('yyyy-MM-dd', $formatter->getPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetTimeType()
|
public function testGetTimeType()
|
||||||
{
|
{
|
||||||
$formatter = $this->getDateFormatter('en', StubIntlDateFormatter::NONE, StubIntlDateFormatter::FULL);
|
$formatter = $this->getDateFormatter('en', IntlDateFormatter::NONE, IntlDateFormatter::FULL);
|
||||||
$this->assertEquals(StubIntlDateFormatter::FULL, $formatter->getTimeType());
|
$this->assertEquals(IntlDateFormatter::FULL, $formatter->getTimeType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -488,7 +488,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testParse($pattern, $value, $expected)
|
public function testParse($pattern, $value, $expected)
|
||||||
{
|
{
|
||||||
$errorCode = StubIntlGlobals::U_ZERO_ERROR;
|
$errorCode = IntlGlobals::U_ZERO_ERROR;
|
||||||
$errorMessage = 'U_ZERO_ERROR';
|
$errorMessage = 'U_ZERO_ERROR';
|
||||||
|
|
||||||
$formatter = $this->getDefaultDateFormatter($pattern);
|
$formatter = $this->getDefaultDateFormatter($pattern);
|
||||||
@ -787,7 +787,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testParseError($pattern, $value)
|
public function testParseError($pattern, $value)
|
||||||
{
|
{
|
||||||
$errorCode = StubIntlGlobals::U_PARSE_ERROR;
|
$errorCode = IntlGlobals::U_PARSE_ERROR;
|
||||||
$errorMessage = 'Date parsing failed: U_PARSE_ERROR';
|
$errorMessage = 'Date parsing failed: U_PARSE_ERROR';
|
||||||
|
|
||||||
$formatter = $this->getDefaultDateFormatter($pattern);
|
$formatter = $this->getDefaultDateFormatter($pattern);
|
||||||
@ -876,7 +876,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function getDefaultDateFormatter($pattern = null)
|
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)
|
protected function getDateTime($timestamp = null)
|
||||||
@ -906,7 +906,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function assertIsIntlSuccess($formatter, $errorMessage, $errorCode)
|
protected function assertIsIntlSuccess($formatter, $errorMessage, $errorCode)
|
||||||
{
|
{
|
||||||
/* @var StubIntlDateFormatter $formatter */
|
/* @var IntlDateFormatter $formatter */
|
||||||
$this->assertSame($errorMessage, $this->getIntlErrorMessage());
|
$this->assertSame($errorMessage, $this->getIntlErrorMessage());
|
||||||
$this->assertSame($errorCode, $this->getIntlErrorCode());
|
$this->assertSame($errorCode, $this->getIntlErrorCode());
|
||||||
$this->assertFalse($this->isIntlFailure($this->getIntlErrorCode()));
|
$this->assertFalse($this->isIntlFailure($this->getIntlErrorCode()));
|
||||||
@ -925,7 +925,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @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
|
* @return string
|
||||||
|
@ -11,15 +11,15 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\Tests\DateFormatter;
|
namespace Symfony\Component\Intl\Tests\DateFormatter;
|
||||||
|
|
||||||
use Symfony\Component\Intl\DateFormatter\StubIntlDateFormatter;
|
use Symfony\Component\Intl\DateFormatter\IntlDateFormatter;
|
||||||
use Symfony\Component\Intl\Globals\StubIntlGlobals;
|
use Symfony\Component\Intl\Globals\IntlGlobals;
|
||||||
use Symfony\Component\Intl\Util\Version;
|
use Symfony\Component\Intl\Util\Version;
|
||||||
|
|
||||||
class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
||||||
{
|
{
|
||||||
public function testConstructor()
|
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());
|
$this->assertEquals('y-M-d', $formatter->getPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,13 +28,13 @@ class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testConstructorWithUnsupportedLocale()
|
public function testConstructorWithUnsupportedLocale()
|
||||||
{
|
{
|
||||||
new StubIntlDateFormatter('pt_BR', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
|
new IntlDateFormatter('pt_BR', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStaticCreate()
|
public function testStaticCreate()
|
||||||
{
|
{
|
||||||
$formatter = StubIntlDateFormatter::create('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT);
|
$formatter = IntlDateFormatter::create('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
|
||||||
$this->assertInstanceOf('Symfony\Component\Intl\DateFormatter\StubIntlDateFormatter', $formatter);
|
$this->assertInstanceOf('\Symfony\Component\Intl\DateFormatter\IntlDateFormatter', $formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormatWithUnsupportedTimestampArgument()
|
public function testFormatWithUnsupportedTimestampArgument()
|
||||||
@ -72,7 +72,7 @@ class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
|||||||
public function testFormatWithUnimplementedChars()
|
public function testFormatWithUnimplementedChars()
|
||||||
{
|
{
|
||||||
$pattern = 'Y';
|
$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);
|
$formatter->format(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,13 +88,13 @@ class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
|||||||
public function testGetErrorCode()
|
public function testGetErrorCode()
|
||||||
{
|
{
|
||||||
$formatter = $this->getDefaultDateFormatter();
|
$formatter = $this->getDefaultDateFormatter();
|
||||||
$this->assertEquals(StubIntlGlobals::getErrorCode(), $formatter->getErrorCode());
|
$this->assertEquals(IntlGlobals::getErrorCode(), $formatter->getErrorCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetErrorMessage()
|
public function testGetErrorMessage()
|
||||||
{
|
{
|
||||||
$formatter = $this->getDefaultDateFormatter();
|
$formatter = $this->getDefaultDateFormatter();
|
||||||
$this->assertEquals(StubIntlGlobals::getErrorMessage(), $formatter->getErrorMessage());
|
$this->assertEquals(IntlGlobals::getErrorMessage(), $formatter->getErrorMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsLenient()
|
public function testIsLenient()
|
||||||
@ -128,7 +128,7 @@ class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
|||||||
public function testSetCalendar()
|
public function testSetCalendar()
|
||||||
{
|
{
|
||||||
$formatter = $this->getDefaultDateFormatter();
|
$formatter = $this->getDefaultDateFormatter();
|
||||||
$formatter->setCalendar(StubIntlDateFormatter::GREGORIAN);
|
$formatter->setCalendar(IntlDateFormatter::GREGORIAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,24 +176,24 @@ class StubIntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
|||||||
return $this->notImplemented(parent::parseQuarterProvider());
|
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()
|
protected function getIntlErrorMessage()
|
||||||
{
|
{
|
||||||
return StubIntlGlobals::getErrorMessage();
|
return IntlGlobals::getErrorMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getIntlErrorCode()
|
protected function getIntlErrorCode()
|
||||||
{
|
{
|
||||||
return StubIntlGlobals::getErrorCode();
|
return IntlGlobals::getErrorCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function isIntlFailure($errorCode)
|
protected function isIntlFailure($errorCode)
|
||||||
{
|
{
|
||||||
return StubIntlGlobals::isFailure($errorCode);
|
return IntlGlobals::isFailure($errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\Tests\DateFormatter\Verification;
|
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\Tests\DateFormatter\AbstractIntlDateFormatterTest;
|
||||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
use Symfony\Component\Intl\Util\IntlTestHelper;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
|||||||
parent::testFormatWithTimezoneFromEnvironmentVariable();
|
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);
|
return new \IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\Tests\Globals;
|
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)
|
protected function getIntlErrorName($errorCode)
|
||||||
{
|
{
|
||||||
return StubIntlGlobals::getErrorName($errorCode);
|
return IntlGlobals::getErrorName($errorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\Tests\Locale;
|
namespace Symfony\Component\Intl\Tests\Locale;
|
||||||
|
|
||||||
class StubLocaleTest extends AbstractLocaleTest
|
class LocaleTest extends AbstractLocaleTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
|
* @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
|
||||||
@ -154,6 +154,6 @@ class StubLocaleTest extends AbstractLocaleTest
|
|||||||
{
|
{
|
||||||
$args = array_slice(func_get_args(), 1);
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\Tests\NumberFormatter;
|
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\Intl;
|
||||||
use Symfony\Component\Intl\Locale;
|
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\IcuVersion;
|
||||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
use Symfony\Component\Intl\Util\IntlTestHelper;
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatCurrencyWithDecimalStyle($value, $currency, $expected)
|
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));
|
$this->assertEquals($expected, $formatter->formatCurrency($value, $currency));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatCurrencyWithCurrencyStyle($value, $currency, $expected)
|
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));
|
$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)
|
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));
|
$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)
|
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));
|
$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)
|
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));
|
$this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,10 +158,10 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testFormat()
|
public function testFormat()
|
||||||
{
|
{
|
||||||
$errorCode = StubIntlGlobals::U_ZERO_ERROR;
|
$errorCode = IntlGlobals::U_ZERO_ERROR;
|
||||||
$errorMessage = '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('9.555', $formatter->format(9.555));
|
||||||
|
|
||||||
$this->assertSame($errorMessage, $this->getIntlErrorMessage());
|
$this->assertSame($errorMessage, $this->getIntlErrorMessage());
|
||||||
@ -174,7 +174,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testFormatWithCurrencyStyle()
|
public function testFormatWithCurrencyStyle()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
|
||||||
$this->assertEquals('¤1.00', $formatter->format(1));
|
$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 = '')
|
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);
|
$this->assertEquals($expected, $formattedValue, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatTypeInt32Provider()
|
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.';
|
$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 = '')
|
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);
|
$this->assertEquals($expected, $formattedValue, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatTypeInt32WithCurrencyStyleProvider()
|
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.';
|
$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)
|
public function testFormatTypeInt64($formatter, $value, $expected)
|
||||||
{
|
{
|
||||||
$formattedValue = $formatter->format($value, StubNumberFormatter::TYPE_INT64);
|
$formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT64);
|
||||||
$this->assertEquals($expected, $formattedValue);
|
$this->assertEquals($expected, $formattedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatTypeInt64Provider()
|
public function formatTypeInt64Provider()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
array($formatter, 1, '1'),
|
array($formatter, 1, '1'),
|
||||||
@ -251,13 +251,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected)
|
public function testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected)
|
||||||
{
|
{
|
||||||
$formattedValue = $formatter->format($value, StubNumberFormatter::TYPE_INT64);
|
$formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT64);
|
||||||
$this->assertEquals($expected, $formattedValue);
|
$this->assertEquals($expected, $formattedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatTypeInt64WithCurrencyStyleProvider()
|
public function formatTypeInt64WithCurrencyStyleProvider()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
array($formatter, 1, '¤1.00'),
|
array($formatter, 1, '¤1.00'),
|
||||||
@ -272,13 +272,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatTypeDouble($formatter, $value, $expected)
|
public function testFormatTypeDouble($formatter, $value, $expected)
|
||||||
{
|
{
|
||||||
$formattedValue = $formatter->format($value, StubNumberFormatter::TYPE_DOUBLE);
|
$formattedValue = $formatter->format($value, NumberFormatter::TYPE_DOUBLE);
|
||||||
$this->assertEquals($expected, $formattedValue);
|
$this->assertEquals($expected, $formattedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatTypeDoubleProvider()
|
public function formatTypeDoubleProvider()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
array($formatter, 1, '1'),
|
array($formatter, 1, '1'),
|
||||||
@ -291,13 +291,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected)
|
public function testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected)
|
||||||
{
|
{
|
||||||
$formattedValue = $formatter->format($value, StubNumberFormatter::TYPE_DOUBLE);
|
$formattedValue = $formatter->format($value, NumberFormatter::TYPE_DOUBLE);
|
||||||
$this->assertEquals($expected, $formattedValue);
|
$this->assertEquals($expected, $formattedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatTypeDoubleWithCurrencyStyleProvider()
|
public function formatTypeDoubleWithCurrencyStyleProvider()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
array($formatter, 1, '¤1.00'),
|
array($formatter, 1, '¤1.00'),
|
||||||
@ -311,7 +311,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatTypeCurrency($formatter, $value)
|
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)
|
public function testFormatTypeCurrencyReturn($formatter, $value)
|
||||||
{
|
{
|
||||||
$this->assertFalse(@$formatter->format($value, StubNumberFormatter::TYPE_CURRENCY));
|
$this->assertFalse(@$formatter->format($value, NumberFormatter::TYPE_CURRENCY));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatTypeCurrencyProvider()
|
public function formatTypeCurrencyProvider()
|
||||||
{
|
{
|
||||||
$df = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$df = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$cf = $this->getNumberFormatter('en', StubNumberFormatter::CURRENCY);
|
$cf = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
array($df, 1),
|
array($df, 1),
|
||||||
@ -338,15 +338,15 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatFractionDigits($value, $expected, $fractionDigits = null, $expectedFractionDigits = 1)
|
public function testFormatFractionDigits($value, $expected, $fractionDigits = null, $expectedFractionDigits = 1)
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
|
|
||||||
if (null !== $fractionDigits) {
|
if (null !== $fractionDigits) {
|
||||||
$attributeRet = $formatter->setAttribute(StubNumberFormatter::FRACTION_DIGITS, $fractionDigits);
|
$attributeRet = $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $fractionDigits);
|
||||||
}
|
}
|
||||||
|
|
||||||
$formattedValue = $formatter->format($value);
|
$formattedValue = $formatter->format($value);
|
||||||
$this->assertSame($expected, $formattedValue);
|
$this->assertSame($expected, $formattedValue);
|
||||||
$this->assertSame($expectedFractionDigits, $formatter->getAttribute(StubNumberFormatter::FRACTION_DIGITS));
|
$this->assertSame($expectedFractionDigits, $formatter->getAttribute(NumberFormatter::FRACTION_DIGITS));
|
||||||
|
|
||||||
if (isset($attributeRet)) {
|
if (isset($attributeRet)) {
|
||||||
$this->assertTrue($attributeRet);
|
$this->assertTrue($attributeRet);
|
||||||
@ -370,15 +370,15 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatGroupingUsed($value, $expected, $groupingUsed = null, $expectedGroupingUsed = 1)
|
public function testFormatGroupingUsed($value, $expected, $groupingUsed = null, $expectedGroupingUsed = 1)
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
|
|
||||||
if (null !== $groupingUsed) {
|
if (null !== $groupingUsed) {
|
||||||
$attributeRet = $formatter->setAttribute(StubNumberFormatter::GROUPING_USED, $groupingUsed);
|
$attributeRet = $formatter->setAttribute(NumberFormatter::GROUPING_USED, $groupingUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
$formattedValue = $formatter->format($value);
|
$formattedValue = $formatter->format($value);
|
||||||
$this->assertSame($expected, $formattedValue);
|
$this->assertSame($expected, $formattedValue);
|
||||||
$this->assertSame($expectedGroupingUsed, $formatter->getAttribute(StubNumberFormatter::GROUPING_USED));
|
$this->assertSame($expectedGroupingUsed, $formatter->getAttribute(NumberFormatter::GROUPING_USED));
|
||||||
|
|
||||||
if (isset($attributeRet)) {
|
if (isset($attributeRet)) {
|
||||||
$this->assertTrue($attributeRet);
|
$this->assertTrue($attributeRet);
|
||||||
@ -402,10 +402,10 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatRoundingModeHalfUp($value, $expected)
|
public function testFormatRoundingModeHalfUp($value, $expected)
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->setAttribute(StubNumberFormatter::FRACTION_DIGITS, 2);
|
$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.');
|
$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)
|
public function testFormatRoundingModeHalfDown($value, $expected)
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->setAttribute(StubNumberFormatter::FRACTION_DIGITS, 2);
|
$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.');
|
$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)
|
public function testFormatRoundingModeHalfEven($value, $expected)
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->setAttribute(StubNumberFormatter::FRACTION_DIGITS, 2);
|
$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.');
|
$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()
|
public function testGetLocale()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$this->assertEquals('en', $formatter->getLocale());
|
$this->assertEquals('en', $formatter->getLocale());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,15 +478,15 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testParse($value, $expected, $message = '')
|
public function testParse($value, $expected, $message = '')
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$parsedValue = $formatter->parse($value, StubNumberFormatter::TYPE_DOUBLE);
|
$parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE);
|
||||||
$this->assertSame($expected, $parsedValue, $message);
|
$this->assertSame($expected, $parsedValue, $message);
|
||||||
|
|
||||||
if ($expected === false) {
|
if ($expected === false) {
|
||||||
$errorCode = StubIntlGlobals::U_PARSE_ERROR;
|
$errorCode = IntlGlobals::U_PARSE_ERROR;
|
||||||
$errorMessage = 'Number parsing failed: U_PARSE_ERROR';
|
$errorMessage = 'Number parsing failed: U_PARSE_ERROR';
|
||||||
} else {
|
} else {
|
||||||
$errorCode = StubIntlGlobals::U_ZERO_ERROR;
|
$errorCode = IntlGlobals::U_ZERO_ERROR;
|
||||||
$errorMessage = 'U_ZERO_ERROR';
|
$errorMessage = 'U_ZERO_ERROR';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,8 +511,8 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testParseTypeDefault()
|
public function testParseTypeDefault()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->parse('1', StubNumberFormatter::TYPE_DEFAULT);
|
$formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -520,8 +520,8 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testParseTypeInt32($value, $expected, $message = '')
|
public function testParseTypeInt32($value, $expected, $message = '')
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$parsedValue = $formatter->parse($value, StubNumberFormatter::TYPE_INT32);
|
$parsedValue = $formatter->parse($value, NumberFormatter::TYPE_INT32);
|
||||||
$this->assertSame($expected, $parsedValue);
|
$this->assertSame($expected, $parsedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,13 +541,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
IntlTestHelper::require32Bit($this);
|
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->assertInternalType('integer', $parsedValue);
|
||||||
$this->assertEquals(2147483647, $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
|
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
|
||||||
// The negative PHP_INT_MAX was being converted to float
|
// The negative PHP_INT_MAX was being converted to float
|
||||||
@ -567,13 +567,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
IntlTestHelper::require64Bit($this);
|
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->assertInternalType('integer', $parsedValue);
|
||||||
$this->assertEquals(2147483647, $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->assertInternalType('integer', $parsedValue);
|
||||||
$this->assertEquals(-2147483647 - 1, $parsedValue);
|
$this->assertEquals(-2147483647 - 1, $parsedValue);
|
||||||
}
|
}
|
||||||
@ -585,14 +585,14 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
IntlTestHelper::require32Bit($this);
|
IntlTestHelper::require32Bit($this);
|
||||||
|
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
|
|
||||||
// int 64 using only 32 bit range strangeness
|
// 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->assertInternalType('float', $parsedValue);
|
||||||
$this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range.');
|
$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->assertInternalType('float', $parsedValue);
|
||||||
$this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range.');
|
$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);
|
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);
|
$this->assertInternalType('integer', $parsedValue);
|
||||||
|
|
||||||
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
|
// 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).');
|
$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);
|
$this->assertInternalType('integer', $parsedValue);
|
||||||
|
|
||||||
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
|
// 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)
|
public function testParseTypeDouble($value, $expectedValue)
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$parsedValue = $formatter->parse($value, StubNumberFormatter::TYPE_DOUBLE);
|
$parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE);
|
||||||
$this->assertSame($expectedValue, $parsedValue);
|
$this->assertSame($expectedValue, $parsedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,23 +660,23 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testParseTypeCurrency()
|
public function testParseTypeCurrency()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->parse('1', StubNumberFormatter::TYPE_CURRENCY);
|
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testParseWithNullPositionValue()
|
public function testParseWithNullPositionValue()
|
||||||
{
|
{
|
||||||
$position = null;
|
$position = null;
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->parse('123', StubNumberFormatter::TYPE_INT32, $position);
|
$formatter->parse('123', NumberFormatter::TYPE_INT32, $position);
|
||||||
$this->assertNull($position);
|
$this->assertNull($position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testParseWithNotNullPositionValue()
|
public function testParseWithNotNullPositionValue()
|
||||||
{
|
{
|
||||||
$position = 1;
|
$position = 1;
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->parse('123', StubNumberFormatter::TYPE_DOUBLE, $position);
|
$formatter->parse('123', NumberFormatter::TYPE_DOUBLE, $position);
|
||||||
$this->assertEquals(3, $position);
|
$this->assertEquals(3, $position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,15 +11,15 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\Tests\NumberFormatter;
|
namespace Symfony\Component\Intl\Tests\NumberFormatter;
|
||||||
|
|
||||||
use Symfony\Component\Intl\Globals\StubIntlGlobals;
|
use Symfony\Component\Intl\Globals\IntlGlobals;
|
||||||
use Symfony\Component\Intl\NumberFormatter\StubNumberFormatter;
|
use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
|
||||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
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
|
* Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known
|
||||||
* behavior of PHP.
|
* behavior of PHP.
|
||||||
*/
|
*/
|
||||||
class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
class NumberFormatterTest extends AbstractNumberFormatterTest
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
@ -33,7 +33,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testConstructorWithUnsupportedLocale()
|
public function testConstructorWithUnsupportedLocale()
|
||||||
{
|
{
|
||||||
new StubNumberFormatter('pt_BR');
|
new NumberFormatter('pt_BR');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +41,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testConstructorWithUnsupportedStyle()
|
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()
|
public function testConstructorWithPatternDifferentThanNull()
|
||||||
{
|
{
|
||||||
new StubNumberFormatter('en', StubNumberFormatter::DECIMAL, '');
|
new NumberFormatter('en', NumberFormatter::DECIMAL, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,8 +57,8 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testSetAttributeWithUnsupportedAttribute()
|
public function testSetAttributeWithUnsupportedAttribute()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->setAttribute(StubNumberFormatter::LENIENT_PARSE, null);
|
$formatter->setAttribute(NumberFormatter::LENIENT_PARSE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,15 +66,15 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testSetAttributeInvalidRoundingMode()
|
public function testSetAttributeInvalidRoundingMode()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->setAttribute(StubNumberFormatter::ROUNDING_MODE, null);
|
$formatter->setAttribute(NumberFormatter::ROUNDING_MODE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreate()
|
public function testCreate()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
'Symfony\Component\Intl\NumberFormatter\StubNumberFormatter',
|
'\Symfony\Component\Intl\NumberFormatter\NumberFormatter',
|
||||||
StubNumberFormatter::create('en', StubNumberFormatter::DECIMAL)
|
NumberFormatter::create('en', NumberFormatter::DECIMAL)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testGetPattern()
|
public function testGetPattern()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->getPattern();
|
$formatter->getPattern();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testGetSymbol()
|
public function testGetSymbol()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->getSymbol(null);
|
$formatter->getSymbol(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,14 +163,14 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testGetTextAttribute()
|
public function testGetTextAttribute()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->getTextAttribute(null);
|
$formatter->getTextAttribute(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetErrorCode()
|
public function testGetErrorCode()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$this->assertEquals(StubIntlGlobals::U_ZERO_ERROR, $formatter->getErrorCode());
|
$this->assertEquals(IntlGlobals::U_ZERO_ERROR, $formatter->getErrorCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -178,7 +178,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testParseCurrency()
|
public function testParseCurrency()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->parseCurrency(null, $currency);
|
$formatter->parseCurrency(null, $currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testSetPattern()
|
public function testSetPattern()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->setPattern(null);
|
$formatter->setPattern(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testSetSymbol()
|
public function testSetSymbol()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->setSymbol(null, null);
|
$formatter->setSymbol(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,27 +213,27 @@ class StubNumberFormatterTest extends AbstractNumberFormatterTest
|
|||||||
*/
|
*/
|
||||||
public function testSetTextAttribute()
|
public function testSetTextAttribute()
|
||||||
{
|
{
|
||||||
$formatter = $this->getNumberFormatter('en', StubNumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->setTextAttribute(null, null);
|
$formatter->setTextAttribute(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getNumberFormatter($locale = 'en', $style = null, $pattern = 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()
|
protected function getIntlErrorMessage()
|
||||||
{
|
{
|
||||||
return StubIntlGlobals::getErrorMessage();
|
return IntlGlobals::getErrorMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getIntlErrorCode()
|
protected function getIntlErrorCode()
|
||||||
{
|
{
|
||||||
return StubIntlGlobals::getErrorCode();
|
return IntlGlobals::getErrorCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function isIntlFailure($errorCode)
|
protected function isIntlFailure($errorCode)
|
||||||
{
|
{
|
||||||
return StubIntlGlobals::isFailure($errorCode);
|
return IntlGlobals::isFailure($errorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user