Skip to content

Commit 548c5ea

Browse files
committed
IHF: multiarray_sort_by tests added.
1 parent 4d746b1 commit 548c5ea

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/array/MultiarraySortByTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,26 @@ public function it_can_sort_by_two_fields_with_specifying_asc_sort_order_only_fo
116116
$this->assertEquals($expected, multiarray_sort_by($array, 'name', 'model', SORT_ASC));
117117
}
118118

119+
/** @test */
120+
public function it_can_sort_by_two_fields_with_specifying_desc_sort_order_only_for_the_second()
121+
{
122+
$array = [
123+
['name' => 'Mercedes-Benz', 'model' => 'GLS', 'price' => 120000],
124+
['name' => 'Mercedes-Benz', 'model' => 'GLE Coupe', 'price' => 110000],
125+
['name' => 'BMW', 'model' => 'X6', 'price' => 77000],
126+
['name' => 'Porsche', 'model' => 'Cayenne', 'price' => 117000],
127+
];
128+
129+
$expected = [
130+
['name' => 'BMW', 'model' => 'X6', 'price' => 77000],
131+
['name' => 'Mercedes-Benz', 'model' => 'GLS', 'price' => 120000],
132+
['name' => 'Mercedes-Benz', 'model' => 'GLE Coupe', 'price' => 110000],
133+
['name' => 'Porsche', 'model' => 'Cayenne', 'price' => 117000],
134+
];
135+
136+
$this->assertEquals($expected, multiarray_sort_by($array, 'name', 'model', SORT_DESC));
137+
}
138+
119139
/** @test */
120140
public function it_can_sort_by_two_fields_with_specifying_asc_sort_order_for_both()
121141
{

0 commit comments

Comments
 (0)