Вход Регистрация
Файл: symfony-2.7/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php
Строк: 319
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace SymfonyComponentIntlTestsNumberFormatter;

use 
SymfonyComponentIntlGlobalsIntlGlobals;
use 
SymfonyComponentIntlNumberFormatterNumberFormatter;
use 
SymfonyComponentIntlUtilIntlTestHelper;

/**
 * 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 NumberFormatterTest extends AbstractNumberFormatterTest
{
    protected function 
setUp()
    {
        
IntlTestHelper::requireIntl($this);

        
parent::setUp();
    }

    
/**
     * @expectedException SymfonyComponentIntlExceptionMethodArgumentValueNotImplementedException
     */
    
public function testConstructorWithUnsupportedLocale()
    {
        new 
NumberFormatter('pt_BR');
    }

    
/**
     * @expectedException SymfonyComponentIntlExceptionMethodArgumentValueNotImplementedException
     */
    
public function testConstructorWithUnsupportedStyle()
    {
        new 
NumberFormatter('en'NumberFormatter::PATTERN_DECIMAL);
    }

    
/**
     * @expectedException SymfonyComponentIntlExceptionMethodArgumentNotImplementedException
     */
    
public function testConstructorWithPatternDifferentThanNull()
    {
        new 
NumberFormatter('en'NumberFormatter::DECIMAL'');
    }

    
/**
     * @expectedException SymfonyComponentIntlExceptionMethodArgumentValueNotImplementedException
     */
    
public function testSetAttributeWithUnsupportedAttribute()
    {
        
$formatter $this->getNumberFormatter('en'NumberFormatter::DECIMAL);
        
$formatter->setAttribute(NumberFormatter::LENIENT_PARSEnull);
    }

    
/**
     * @expectedException SymfonyComponentIntlExceptionMethodArgumentValueNotImplementedException
     */
    
public function testSetAttributeInvalidRoundingMode()
    {
        
$formatter $this->getNumberFormatter('en'NumberFormatter::DECIMAL);
        
$formatter->setAttribute(NumberFormatter::ROUNDING_MODEnull);
    }

    public function 
testCreate()
    {
        
$this->assertInstanceOf(
            
'SymfonyComponentIntlNumberFormatterNumberFormatter',
            
NumberFormatter::create('en'NumberFormatter::DECIMAL)
        );
    }

    
/**
     * @expectedException RuntimeException
     */
    
public function testFormatWithCurrencyStyle()
    {
        
parent::testFormatWithCurrencyStyle();
    }

    
/**
     * @dataProvider formatTypeInt32Provider
     * @expectedException SymfonyComponentIntlExceptionMethodArgumentValueNotImplementedException
     */
    
public function testFormatTypeInt32($formatter$value$expected$message '')
    {
        
parent::testFormatTypeInt32($formatter$value$expected$message);
    }

    
/**
     * @dataProvider formatTypeInt32WithCurrencyStyleProvider
     * @expectedException SymfonyComponentIntlExceptionNotImplementedException
     */
    
public function testFormatTypeInt32WithCurrencyStyle($formatter$value$expected$message '')
    {
        
parent::testFormatTypeInt32WithCurrencyStyle($formatter$value$expected$message);
    }

    
/**
     * @dataProvider formatTypeInt64Provider
     * @expectedException SymfonyComponentIntlExceptionMethodArgumentValueNotImplementedException
     */
    
public function testFormatTypeInt64($formatter$value$expected)
    {
        
parent::testFormatTypeInt64($formatter$value$expected);
    }

    
/**
     * @dataProvider formatTypeInt64WithCurrencyStyleProvider
     * @expectedException SymfonyComponentIntlExceptionNotImplementedException
     */
    
public function testFormatTypeInt64WithCurrencyStyle($formatter$value$expected)
    {
        
parent::testFormatTypeInt64WithCurrencyStyle($formatter$value$expected);
    }

    
/**
     * @dataProvider formatTypeDoubleProvider
     * @expectedException SymfonyComponentIntlExceptionMethodArgumentValueNotImplementedException
     */
    
public function testFormatTypeDouble($formatter$value$expected)
    {
        
parent::testFormatTypeDouble($formatter$value$expected);
    }

    
/**
     * @dataProvider formatTypeDoubleWithCurrencyStyleProvider
     * @expectedException SymfonyComponentIntlExceptionNotImplementedException
     */
    
public function testFormatTypeDoubleWithCurrencyStyle($formatter$value$expected)
    {
        
parent::testFormatTypeDoubleWithCurrencyStyle($formatter$value$expected);
    }

    
/**
     * @expectedException SymfonyComponentIntlExceptionMethodNotImplementedException
     */
    
public function testGetPattern()
    {
        
$formatter $this->getNumberFormatter('en'NumberFormatter::DECIMAL);
        
$formatter->getPattern();
    }

    public function 
testGetErrorCode()
    {
        
$formatter $this->getNumberFormatter('en'NumberFormatter::DECIMAL);
        
$this->assertEquals(IntlGlobals::U_ZERO_ERROR$formatter->getErrorCode());
    }

    
/**
     * @expectedException SymfonyComponentIntlExceptionMethodNotImplementedException
     */
    
public function testParseCurrency()
    {
        
$formatter $this->getNumberFormatter('en'NumberFormatter::DECIMAL);
        
$formatter->parseCurrency(null$currency);
    }

    
/**
     * @expectedException SymfonyComponentIntlExceptionMethodNotImplementedException
     */
    
public function testSetPattern()
    {
        
$formatter $this->getNumberFormatter('en'NumberFormatter::DECIMAL);
        
$formatter->setPattern(null);
    }

    
/**
     * @expectedException SymfonyComponentIntlExceptionMethodNotImplementedException
     */
    
public function testSetSymbol()
    {
        
$formatter $this->getNumberFormatter('en'NumberFormatter::DECIMAL);
        
$formatter->setSymbol(nullnull);
    }

    
/**
     * @expectedException SymfonyComponentIntlExceptionMethodNotImplementedException
     */
    
public function testSetTextAttribute()
    {
        
$formatter $this->getNumberFormatter('en'NumberFormatter::DECIMAL);
        
$formatter->setTextAttribute(nullnull);
    }

    protected function 
getNumberFormatter($locale 'en'$style null$pattern null)
    {
        return new 
NumberFormatter($locale$style$pattern);
    }

    protected function 
getIntlErrorMessage()
    {
        return 
IntlGlobals::getErrorMessage();
    }

    protected function 
getIntlErrorCode()
    {
        return 
IntlGlobals::getErrorCode();
    }

    protected function 
isIntlFailure($errorCode)
    {
        return 
IntlGlobals::isFailure($errorCode);
    }
}
Онлайн: 0
Реклама