]>
Commit | Line | Data |
---|---|---|
4f5b44bd NL |
1 | <?php |
2 | ||
3 | /* | |
4 | * This file is part of the Symfony package. | |
5 | * | |
6 | * (c) Fabien Potencier <fabien@symfony.com> | |
7 | * | |
8 | * For the full copyright and license information, please view the LICENSE | |
9 | * file that was distributed with this source code. | |
10 | */ | |
11 | ||
12 | namespace Symfony\Component\Intl\Tests\Collator; | |
13 | ||
14 | use Symfony\Component\Intl\Collator\Collator; | |
15 | use Symfony\Component\Intl\Globals\IntlGlobals; | |
16 | ||
17 | class CollatorTest extends AbstractCollatorTest | |
18 | { | |
19 | /** | |
20 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException | |
21 | */ | |
22 | public function testConstructorWithUnsupportedLocale() | |
23 | { | |
24 | new Collator('pt_BR'); | |
25 | } | |
26 | ||
27 | /** | |
28 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | |
29 | */ | |
30 | public function testCompare() | |
31 | { | |
32 | $collator = $this->getCollator('en'); | |
33 | $collator->compare('a', 'b'); | |
34 | } | |
35 | ||
36 | /** | |
37 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | |
38 | */ | |
39 | public function testGetAttribute() | |
40 | { | |
41 | $collator = $this->getCollator('en'); | |
42 | $collator->getAttribute(Collator::NUMERIC_COLLATION); | |
43 | } | |
44 | ||
45 | public function testGetErrorCode() | |
46 | { | |
47 | $collator = $this->getCollator('en'); | |
48 | $this->assertEquals(IntlGlobals::U_ZERO_ERROR, $collator->getErrorCode()); | |
49 | } | |
50 | ||
51 | public function testGetErrorMessage() | |
52 | { | |
53 | $collator = $this->getCollator('en'); | |
54 | $this->assertEquals('U_ZERO_ERROR', $collator->getErrorMessage()); | |
55 | } | |
56 | ||
57 | public function testGetLocale() | |
58 | { | |
59 | $collator = $this->getCollator('en'); | |
60 | $this->assertEquals('en', $collator->getLocale()); | |
61 | } | |
62 | ||
63 | /** | |
64 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | |
65 | */ | |
66 | public function testGetSortKey() | |
67 | { | |
68 | $collator = $this->getCollator('en'); | |
69 | $collator->getSortKey('Hello'); | |
70 | } | |
71 | ||
72 | /** | |
73 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | |
74 | */ | |
75 | public function testGetStrength() | |
76 | { | |
77 | $collator = $this->getCollator('en'); | |
78 | $collator->getStrength(); | |
79 | } | |
80 | ||
81 | /** | |
82 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | |
83 | */ | |
84 | public function testSetAttribute() | |
85 | { | |
86 | $collator = $this->getCollator('en'); | |
87 | $collator->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON); | |
88 | } | |
89 | ||
90 | /** | |
91 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | |
92 | */ | |
93 | public function testSetStrength() | |
94 | { | |
95 | $collator = $this->getCollator('en'); | |
96 | $collator->setStrength(Collator::PRIMARY); | |
97 | } | |
98 | ||
99 | public function testStaticCreate() | |
100 | { | |
101 | $collator = Collator::create('en'); | |
102 | $this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator); | |
103 | } | |
104 | ||
105 | protected function getCollator($locale) | |
106 | { | |
107 | return new Collator($locale); | |
108 | } | |
109 | } |