2013-03-01 17:49:04 +00:00
|
|
|
<?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;
|
|
|
|
|
2013-04-11 10:28:48 +01:00
|
|
|
use Symfony\Component\Intl\Collator\Collator;
|
|
|
|
use Symfony\Component\Intl\Globals\IntlGlobals;
|
2013-03-01 17:49:04 +00:00
|
|
|
|
2013-04-11 10:28:48 +01:00
|
|
|
class CollatorTest extends AbstractCollatorTest
|
2013-03-01 17:49:04 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
|
|
|
|
*/
|
|
|
|
public function testConstructorWithUnsupportedLocale()
|
|
|
|
{
|
2013-04-11 10:28:48 +01:00
|
|
|
new Collator('pt_BR');
|
2013-03-01 17:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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');
|
2013-04-11 10:28:48 +01:00
|
|
|
$collator->getAttribute(Collator::NUMERIC_COLLATION);
|
2013-03-01 17:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetErrorCode()
|
|
|
|
{
|
|
|
|
$collator = $this->getCollator('en');
|
2013-04-11 10:28:48 +01:00
|
|
|
$this->assertEquals(IntlGlobals::U_ZERO_ERROR, $collator->getErrorCode());
|
2013-03-01 17:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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');
|
2013-04-11 10:28:48 +01:00
|
|
|
$collator->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON);
|
2013-03-01 17:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
|
|
|
|
*/
|
|
|
|
public function testSetStrength()
|
|
|
|
{
|
|
|
|
$collator = $this->getCollator('en');
|
2013-04-11 10:28:48 +01:00
|
|
|
$collator->setStrength(Collator::PRIMARY);
|
2013-03-01 17:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testStaticCreate()
|
|
|
|
{
|
2013-04-11 10:28:48 +01:00
|
|
|
$collator = Collator::create('en');
|
|
|
|
$this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
|
2013-03-01 17:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getCollator($locale)
|
|
|
|
{
|
2013-04-11 10:28:48 +01:00
|
|
|
return new Collator($locale);
|
2013-03-01 17:49:04 +00:00
|
|
|
}
|
|
|
|
}
|