Browse Source

added test for ArrayHelper::multisort() with closure key

related to #13248
tags/2.0.11
Carsten Brandt 8 years ago
parent
commit
c4857176ac
No known key found for this signature in database
GPG Key ID: BE4F41DE1DEEEED0
  1. 26
      tests/framework/helpers/ArrayHelperTest.php

26
tests/framework/helpers/ArrayHelperTest.php

@ -298,6 +298,32 @@ class ArrayHelperTest extends TestCase
$this->assertEquals(['name' => 'b', 'age' => 3], $array[2]);
}
public function testMultisortClosure()
{
$changelog = [
'- Enh #123: test1',
'- Bug #125: test2',
'- Bug #123: test2',
'- Enh: test3',
'- Bug: test4',
];
$i = 0;
ArrayHelper::multisort($changelog, function($line) use (&$i) {
if (preg_match('/^- (Enh|Bug)( #\d+)?: .+$/', $line, $m)) {
$o = ['Bug' => 'C', 'Enh' => 'D'];
return $o[$m[1]] . ' ' . (!empty($m[2]) ? $m[2] : 'AAAA' . $i++);
}
return 'B' . $i++;
}, SORT_ASC, SORT_NATURAL);
$this->assertEquals([
'- Bug #123: test2',
'- Bug #125: test2',
'- Bug: test4',
'- Enh #123: test1',
'- Enh: test3',
], $changelog);
}
public function testMerge()
{
$a = [

Loading…
Cancel
Save