4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Intl\Tests\Collator
;
14 use Symfony\Component\Intl\Collator\Collator
;
15 use Symfony\Component\Intl\Globals\IntlGlobals
;
17 class CollatorTest
extends AbstractCollatorTest
20 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
22 public function testConstructorWithUnsupportedLocale()
24 new Collator('pt_BR');
28 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
30 public function testCompare()
32 $collator = $this->getCollator('en');
33 $collator->compare('a', 'b');
37 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
39 public function testGetAttribute()
41 $collator = $this->getCollator('en');
42 $collator->getAttribute(Collator
::NUMERIC_COLLATION
);
45 public function testGetErrorCode()
47 $collator = $this->getCollator('en');
48 $this->assertEquals(IntlGlobals
::U_ZERO_ERROR
, $collator->getErrorCode());
51 public function testGetErrorMessage()
53 $collator = $this->getCollator('en');
54 $this->assertEquals('U_ZERO_ERROR', $collator->getErrorMessage());
57 public function testGetLocale()
59 $collator = $this->getCollator('en');
60 $this->assertEquals('en', $collator->getLocale());
64 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
66 public function testGetSortKey()
68 $collator = $this->getCollator('en');
69 $collator->getSortKey('Hello');
73 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
75 public function testGetStrength()
77 $collator = $this->getCollator('en');
78 $collator->getStrength();
82 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
84 public function testSetAttribute()
86 $collator = $this->getCollator('en');
87 $collator->setAttribute(Collator
::NUMERIC_COLLATION
, Collator
::ON
);
91 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
93 public function testSetStrength()
95 $collator = $this->getCollator('en');
96 $collator->setStrength(Collator
::PRIMARY
);
99 public function testStaticCreate()
101 $collator = Collator
::create('en');
102 $this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
105 protected function getCollator($locale)
107 return new Collator($locale);