aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator')
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php62
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/CollatorTest.php109
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php37
3 files changed, 208 insertions, 0 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php
new file mode 100644
index 00000000..08f3a566
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php
@@ -0,0 +1,62 @@
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
12namespace Symfony\Component\Intl\Tests\Collator;
13
14use Symfony\Component\Intl\Collator\Collator;
15use Symfony\Component\Intl\Locale;
16
17/**
18 * Test case for Collator implementations.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 */
22abstract class AbstractCollatorTest extends \PHPUnit_Framework_TestCase
23{
24 /**
25 * @dataProvider asortProvider
26 */
27 public function testAsort($array, $sortFlag, $expected)
28 {
29 $collator = $this->getCollator('en');
30 $collator->asort($array, $sortFlag);
31 $this->assertSame($expected, $array);
32 }
33
34 public function asortProvider()
35 {
36 return array(
37 /* array, sortFlag, expected */
38 array(
39 array('a', 'b', 'c'),
40 Collator::SORT_REGULAR,
41 array('a', 'b', 'c'),
42 ),
43 array(
44 array('c', 'b', 'a'),
45 Collator::SORT_REGULAR,
46 array(2 => 'a', 1 => 'b', 0 => 'c'),
47 ),
48 array(
49 array('b', 'c', 'a'),
50 Collator::SORT_REGULAR,
51 array(2 => 'a', 0 => 'b', 1 => 'c'),
52 ),
53 );
54 }
55
56 /**
57 * @param string $locale
58 *
59 * @return \Collator
60 */
61 abstract protected function getCollator($locale);
62}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/CollatorTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/CollatorTest.php
new file mode 100644
index 00000000..a4e4e56b
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/CollatorTest.php
@@ -0,0 +1,109 @@
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
12namespace Symfony\Component\Intl\Tests\Collator;
13
14use Symfony\Component\Intl\Collator\Collator;
15use Symfony\Component\Intl\Globals\IntlGlobals;
16
17class 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}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php
new file mode 100644
index 00000000..c8dbc131
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php
@@ -0,0 +1,37 @@
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
12namespace Symfony\Component\Intl\Tests\Collator\Verification;
13
14use Symfony\Component\Intl\Locale;
15use Symfony\Component\Intl\Tests\Collator\AbstractCollatorTest;
16use Symfony\Component\Intl\Util\IntlTestHelper;
17
18/**
19 * Verifies that {@link AbstractCollatorTest} matches the behavior of the
20 * {@link \Collator} class in a specific version of ICU.
21 *
22 * @author Bernhard Schussek <bschussek@gmail.com>
23 */
24class CollatorTest extends AbstractCollatorTest
25{
26 protected function setUp()
27 {
28 IntlTestHelper::requireFullIntl($this);
29
30 parent::setUp();
31 }
32
33 protected function getCollator($locale)
34 {
35 return new \Collator($locale);
36 }
37}