2013-04-25 16:53:29 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
namespace PhpOffice\PhpSpreadsheetTests;
|
2016-08-14 04:08:43 +00:00
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\ReferenceHelper;
|
2017-05-17 22:02:17 +00:00
|
|
|
use PHPUnit_Framework_TestCase;
|
2015-05-29 20:35:35 +00:00
|
|
|
|
2017-05-17 22:02:17 +00:00
|
|
|
class ReferenceHelperTest extends PHPUnit_Framework_TestCase
|
2013-04-25 16:53:29 +00:00
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2013-04-25 16:53:29 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testColumnSort()
|
|
|
|
{
|
2015-05-29 20:35:35 +00:00
|
|
|
$columnBase = $columnExpectedResult = [
|
2016-08-16 15:33:57 +00:00
|
|
|
'A', 'B', 'Z',
|
|
|
|
'AA', 'AB', 'AZ',
|
|
|
|
'BA', 'BB', 'BZ',
|
|
|
|
'ZA', 'ZB', 'ZZ',
|
|
|
|
'AAA', 'AAB', 'AAZ',
|
|
|
|
'ABA', 'ABB', 'ABZ',
|
|
|
|
'AZA', 'AZB', 'AZZ',
|
|
|
|
'BAA', 'BAB', 'BAZ',
|
|
|
|
'BBA', 'BBB', 'BBZ',
|
|
|
|
'BZA', 'BZB', 'BZZ',
|
2015-05-29 20:35:35 +00:00
|
|
|
];
|
2015-05-17 13:00:02 +00:00
|
|
|
shuffle($columnBase);
|
2016-08-16 15:33:57 +00:00
|
|
|
usort($columnBase, [ReferenceHelper::class, 'columnSort']);
|
2015-05-17 13:00:02 +00:00
|
|
|
foreach ($columnBase as $key => $value) {
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($columnExpectedResult[$key], $value);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-25 16:53:29 +00:00
|
|
|
|
2015-05-17 13:00:02 +00:00
|
|
|
public function testColumnReverseSort()
|
|
|
|
{
|
2015-05-29 20:35:35 +00:00
|
|
|
$columnBase = $columnExpectedResult = [
|
2016-08-16 15:33:57 +00:00
|
|
|
'A', 'B', 'Z',
|
|
|
|
'AA', 'AB', 'AZ',
|
|
|
|
'BA', 'BB', 'BZ',
|
|
|
|
'ZA', 'ZB', 'ZZ',
|
|
|
|
'AAA', 'AAB', 'AAZ',
|
|
|
|
'ABA', 'ABB', 'ABZ',
|
|
|
|
'AZA', 'AZB', 'AZZ',
|
|
|
|
'BAA', 'BAB', 'BAZ',
|
|
|
|
'BBA', 'BBB', 'BBZ',
|
|
|
|
'BZA', 'BZB', 'BZZ',
|
2015-05-29 20:35:35 +00:00
|
|
|
];
|
2015-05-17 13:00:02 +00:00
|
|
|
shuffle($columnBase);
|
|
|
|
$columnExpectedResult = array_reverse($columnExpectedResult);
|
2016-08-16 15:33:57 +00:00
|
|
|
usort($columnBase, [ReferenceHelper::class, 'columnReverseSort']);
|
2015-05-17 13:00:02 +00:00
|
|
|
foreach ($columnBase as $key => $value) {
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertEquals($columnExpectedResult[$key], $value);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-25 16:53:29 +00:00
|
|
|
}
|