AbstractCollatorTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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\Component\Intl\Tests\Collator;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Intl\Collator\Collator;
  13. /**
  14. * Test case for Collator implementations.
  15. *
  16. * @author Bernhard Schussek <bschussek@gmail.com>
  17. */
  18. abstract class AbstractCollatorTest extends TestCase
  19. {
  20. /**
  21. * @dataProvider asortProvider
  22. */
  23. public function testAsort($array, $sortFlag, $expected)
  24. {
  25. $collator = $this->getCollator('en');
  26. $collator->asort($array, $sortFlag);
  27. $this->assertSame($expected, $array);
  28. }
  29. public function asortProvider()
  30. {
  31. return array(
  32. /* array, sortFlag, expected */
  33. array(
  34. array('a', 'b', 'c'),
  35. Collator::SORT_REGULAR,
  36. array('a', 'b', 'c'),
  37. ),
  38. array(
  39. array('c', 'b', 'a'),
  40. Collator::SORT_REGULAR,
  41. array(2 => 'a', 1 => 'b', 0 => 'c'),
  42. ),
  43. array(
  44. array('b', 'c', 'a'),
  45. Collator::SORT_REGULAR,
  46. array(2 => 'a', 0 => 'b', 1 => 'c'),
  47. ),
  48. );
  49. }
  50. /**
  51. * @param string $locale
  52. *
  53. * @return \Collator
  54. */
  55. abstract protected function getCollator($locale);
  56. }