Skip to content

Commit d316753

Browse files
committed
IHF: multiarray_sort_by tests added.
1 parent 63fc503 commit d316753

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
@@ -135,4 +135,24 @@ public function it_can_sort_by_two_fields_with_specifying_asc_sort_order_for_bot
135135

136136
$this->assertEquals($expected, multiarray_sort_by($array, 'name', SORT_ASC, 'model', SORT_ASC));
137137
}
138+
139+
/** @test */
140+
public function it_can_sort_by_two_fields_with_specifying_desc_sort_orders()
141+
{
142+
$array = [
143+
['name' => 'Mercedes-Benz', 'model' => 'GLS', 'price' => 120000],
144+
['name' => 'Mercedes-Benz', 'model' => 'GLE Coupe', 'price' => 110000],
145+
['name' => 'BMW', 'model' => 'X6', 'price' => 77000],
146+
['name' => 'Porsche', 'model' => 'Cayenne', 'price' => 117000],
147+
];
148+
149+
$expected = [
150+
['name' => 'Porsche', 'model' => 'Cayenne', 'price' => 117000],
151+
['name' => 'Mercedes-Benz', 'model' => 'GLS', 'price' => 120000],
152+
['name' => 'Mercedes-Benz', 'model' => 'GLE Coupe', 'price' => 110000],
153+
['name' => 'BMW', 'model' => 'X6', 'price' => 77000],
154+
];
155+
156+
$this->assertEquals($expected, multiarray_sort_by($array, 'name', SORT_DESC, 'model', SORT_DESC));
157+
}
138158
}

0 commit comments

Comments
 (0)