File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the FOSUserBundle package.
5+ *
6+ * (c) FriendsOfSymfony <http://friendsofsymfony.github.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 FOS \UserBundle \Tests \Util ;
13+
14+ use FOS \UserBundle \Util \Canonicalizer ;
15+
16+ class CanonicalizerTest extends \PHPUnit_Framework_TestCase
17+ {
18+ /**
19+ * @dataProvider canonicalizeProvider
20+ */
21+ public function testCanonicalize ($ source , $ expectedResult )
22+ {
23+ $ canonicalizer = new Canonicalizer ();
24+ $ this ->assertEquals ($ expectedResult , $ canonicalizer ->canonicalize ($ source ));
25+ }
26+
27+ public function canonicalizeProvider ()
28+ {
29+ return array (
30+ array ('FOO ' , 'foo ' ),
31+ array (chr (171 ), PHP_VERSION_ID < 50600 ? chr (171 ) : '? ' ),
32+ );
33+ }
34+ }
Original file line number Diff line number Diff line change 1313
1414class Canonicalizer implements CanonicalizerInterface
1515{
16+ /**
17+ * {@inheritdoc}
18+ */
1619 public function canonicalize ($ string )
1720 {
18- return mb_convert_case ($ string , MB_CASE_LOWER , mb_detect_encoding ($ string ));
21+ $ encoding = mb_detect_encoding ($ string );
22+ $ result = $ encoding
23+ ? mb_convert_case ($ string , MB_CASE_LOWER , $ encoding )
24+ : mb_convert_case ($ string , MB_CASE_LOWER );
25+
26+ return $ result ;
1927 }
2028}
You can’t perform that action at this time.
0 commit comments