From 30a9a37c0d9ae2903cae5150a75eb01a6b2664fd Mon Sep 17 00:00:00 2001 From: "Md. Mottasin Lemon" Date: Wed, 5 Jun 2024 15:16:03 +0600 Subject: [PATCH 1/2] add-test: Arr::sortRecursiveDesc method --- tests/Support/SupportArrTest.php | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/Support/SupportArrTest.php b/tests/Support/SupportArrTest.php index 2f9b2c85d605..7a1986072baa 100644 --- a/tests/Support/SupportArrTest.php +++ b/tests/Support/SupportArrTest.php @@ -1156,6 +1156,61 @@ public function testSortRecursive() $this->assertEquals($expect, Arr::sortRecursive($array)); } + public function testSortRecursiveDesc() + { + $array = [ + 'empty' => [], + 'nested' => [ + 'level1' => [ + 'level2' => [ + 'level3' => [2,3,1], + ], + 'values' => [4,5,6], + ], + ], + 'mixed' => [ + 'a' => 1, + 2 => 'b', + 'c' => 3, + 1 => 'd', + ], + 'numbered_index' => [ + 1 => 'e', + 3 => 'c', + 4 => 'b', + 5 => 'a', + 2 => 'd', + ], + ]; + + $expect = [ + 'empty' => [], + 'mixed' => [ + 'c' => 3, + 'a' => 1, + 2 => 'b', + 1 => 'd', + ], + 'nested' => [ + 'level1' => [ + 'values' => [6, 5, 4], + 'level2' => [ + 'level3' => [3, 2, 1], + ], + ], + ], + 'numbered_index' => [ + 5 => 'a', + 4 => 'b', + 3 => 'c', + 2 => 'd', + 1 => 'e', + ], + ]; + + $this->assertEquals($expect, Arr::sortRecursiveDesc($array)); + } + public function testToCssClasses() { $classes = Arr::toCssClasses([ From 0e3a7ef0b55537abb17294367dda9da2ead85786 Mon Sep 17 00:00:00 2001 From: "Md. Mottasin Lemon" Date: Wed, 5 Jun 2024 15:45:37 +0600 Subject: [PATCH 2/2] make style-ci happy --- tests/Support/SupportArrTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Support/SupportArrTest.php b/tests/Support/SupportArrTest.php index 7a1986072baa..1fe7e063f334 100644 --- a/tests/Support/SupportArrTest.php +++ b/tests/Support/SupportArrTest.php @@ -1163,9 +1163,9 @@ public function testSortRecursiveDesc() 'nested' => [ 'level1' => [ 'level2' => [ - 'level3' => [2,3,1], + 'level3' => [2, 3, 1], ], - 'values' => [4,5,6], + 'values' => [4, 5, 6], ], ], 'mixed' => [