No Description

ReferenceHelperTest.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. class ReferenceHelperTest extends PHPUnit_Framework_TestCase
  3. {
  4. public function setUp()
  5. {
  6. if (!defined('PHPEXCEL_ROOT')) {
  7. define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
  8. }
  9. require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
  10. }
  11. public function testColumnSort()
  12. {
  13. $columnBase = $columnExpectedResult = array(
  14. 'A','B','Z',
  15. 'AA','AB','AZ',
  16. 'BA','BB','BZ',
  17. 'ZA','ZB','ZZ',
  18. 'AAA','AAB','AAZ',
  19. 'ABA','ABB','ABZ',
  20. 'AZA','AZB','AZZ',
  21. 'BAA','BAB','BAZ',
  22. 'BBA','BBB','BBZ',
  23. 'BZA','BZB','BZZ'
  24. );
  25. shuffle($columnBase);
  26. usort($columnBase, array('PHPExcel_ReferenceHelper','columnSort'));
  27. foreach($columnBase as $key => $value) {
  28. $this->assertEquals($columnExpectedResult[$key], $value);
  29. }
  30. }
  31. public function testColumnReverseSort()
  32. {
  33. $columnBase = $columnExpectedResult = array(
  34. 'A','B','Z',
  35. 'AA','AB','AZ',
  36. 'BA','BB','BZ',
  37. 'ZA','ZB','ZZ',
  38. 'AAA','AAB','AAZ',
  39. 'ABA','ABB','ABZ',
  40. 'AZA','AZB','AZZ',
  41. 'BAA','BAB','BAZ',
  42. 'BBA','BBB','BBZ',
  43. 'BZA','BZB','BZZ'
  44. );
  45. shuffle($columnBase);
  46. $columnExpectedResult = array_reverse($columnExpectedResult);
  47. usort($columnBase, array('PHPExcel_ReferenceHelper','columnReverseSort'));
  48. foreach($columnBase as $key => $value) {
  49. $this->assertEquals($columnExpectedResult[$key], $value);
  50. }
  51. }
  52. }