StubCollatorTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\Locale\Stub;
  11. require_once __DIR__.'/../TestCase.php';
  12. use Symfony\Component\Locale\Locale;
  13. use Symfony\Component\Locale\Stub\StubCollator;
  14. use Symfony\Tests\Component\Locale\TestCase as LocaleTestCase;
  15. class StubCollatorTest extends LocaleTestCase
  16. {
  17. /**
  18. * @expectedException Symfony\Component\Locale\Exception\MethodArgumentValueNotImplementedException
  19. */
  20. public function testConstructorWithUnsupportedLocale()
  21. {
  22. $collator = new StubCollator('pt_BR');
  23. }
  24. /**
  25. * @dataProvider asortProvider
  26. */
  27. public function testAsortStub($array, $sortFlag, $expected)
  28. {
  29. $collator = new StubCollator('en');
  30. $collator->asort($array, $sortFlag);
  31. $this->assertSame($expected, $array);
  32. }
  33. /**
  34. * @dataProvider asortProvider
  35. */
  36. public function testAsortIntl($array, $sortFlag, $expected)
  37. {
  38. $this->skipIfIntlExtensionIsNotLoaded();
  39. $collator = new \Collator('en');
  40. $collator->asort($array, $sortFlag);
  41. $this->assertSame($expected, $array);
  42. }
  43. public function asortProvider()
  44. {
  45. return array(
  46. /* array, sortFlag, expected */
  47. array(
  48. array('a', 'b', 'c'),
  49. StubCollator::SORT_REGULAR,
  50. array('a', 'b', 'c'),
  51. ),
  52. array(
  53. array('c', 'b', 'a'),
  54. StubCollator::SORT_REGULAR,
  55. array(2 => 'a', 1 => 'b', 0 => 'c'),
  56. ),
  57. array(
  58. array('b', 'c', 'a'),
  59. StubCollator::SORT_REGULAR,
  60. array(2 => 'a', 0 => 'b', 1 => 'c'),
  61. ),
  62. );
  63. }
  64. public function testStaticCreate()
  65. {
  66. $collator = StubCollator::create('en');
  67. $this->assertInstanceOf('Symfony\Component\Locale\Stub\StubCollator', $collator);
  68. }
  69. }