This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Intl/Tests/Collator/StubCollatorTest.php

110 lines
2.9 KiB
PHP
Raw Normal View History

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\Tests\Collator;
use Symfony\Component\Intl\Collator\StubCollator;
use Symfony\Component\Intl\Globals\StubIntlGlobals;
class StubCollatorTest extends AbstractCollatorTest
{
/**
* @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
*/
public function testConstructorWithUnsupportedLocale()
{
new StubCollator('pt_BR');
}
/**
* @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
*/
public function testCompare()
{
$collator = $this->getCollator('en');
$collator->compare('a', 'b');
}
/**
* @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
*/
public function testGetAttribute()
{
$collator = $this->getCollator('en');
$collator->getAttribute(StubCollator::NUMERIC_COLLATION);
}
public function testGetErrorCode()
{
$collator = $this->getCollator('en');
$this->assertEquals(StubIntlGlobals::U_ZERO_ERROR, $collator->getErrorCode());
}
public function testGetErrorMessage()
{
$collator = $this->getCollator('en');
$this->assertEquals('U_ZERO_ERROR', $collator->getErrorMessage());
}
public function testGetLocale()
{
$collator = $this->getCollator('en');
$this->assertEquals('en', $collator->getLocale());
}
/**
* @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
*/
public function testGetSortKey()
{
$collator = $this->getCollator('en');
$collator->getSortKey('Hello');
}
/**
* @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
*/
public function testGetStrength()
{
$collator = $this->getCollator('en');
$collator->getStrength();
}
/**
* @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
*/
public function testSetAttribute()
{
$collator = $this->getCollator('en');
$collator->setAttribute(StubCollator::NUMERIC_COLLATION, StubCollator::ON);
}
/**
* @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
*/
public function testSetStrength()
{
$collator = $this->getCollator('en');
$collator->setStrength(StubCollator::PRIMARY);
}
public function testStaticCreate()
{
$collator = StubCollator::create('en');
$this->assertInstanceOf('Symfony\Component\Intl\Collator\StubCollator', $collator);
}
protected function getCollator($locale)
{
return new StubCollator($locale);
}
}