Skip to content

Commit

Permalink
Add ReferenceHelper::cellSort and ReferenceHelper::cellReverseSort tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOfDeath authored and PowerKiKi committed Nov 17, 2019
1 parent 82b3a36 commit 7e1bf82
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/PhpSpreadsheetTests/ReferenceHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,46 @@ public function testColumnReverseSort()
self::assertEquals($columnExpectedResult[$key], $value);
}
}

public function testCellSort()
{
$cellBase = $columnExpectedResult = [
'A1', 'B1', 'AZB1',
'BBB1', 'BB2', 'BAB2',
'BZA2', 'Z3', 'AZA3',
'BZB3', 'AB5', 'AZ6',
'ABZ7', 'BA9', 'BZ9',
'AAA9', 'AAZ9', 'BA10',
'BZZ10', 'ZA11', 'AAB11',
'BBZ29', 'BAA32', 'ZZ43',
'AZZ43', 'BAZ67', 'ZB78',
'ABA121', 'ABB289', 'BBA544',
];
shuffle($cellBase);
usort($cellBase, [ReferenceHelper::class, 'cellSort']);
foreach ($cellBase as $key => $value) {
self::assertEquals($columnExpectedResult[$key], $value);
}
}

public function testCellReverseSort()
{
$cellBase = $columnExpectedResult = [
'BBA544', 'ABB289', 'ABA121',
'ZB78', 'BAZ67', 'AZZ43',
'ZZ43', 'BAA32', 'BBZ29',
'AAB11', 'ZA11', 'BZZ10',
'BA10', 'AAZ9', 'AAA9',
'BZ9', 'BA9', 'ABZ7',
'AZ6', 'AB5', 'BZB3',
'AZA3', 'Z3', 'BZA2',
'BAB2', 'BB2', 'BBB1',
'AZB1', 'B1', 'A1',
];
shuffle($cellBase);
usort($cellBase, [ReferenceHelper::class, 'cellReverseSort']);
foreach ($cellBase as $key => $value) {
self::assertEquals($columnExpectedResult[$key], $value);
}
}
}

0 comments on commit 7e1bf82

Please sign in to comment.