Skip to content

Commit 4d746b1

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

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
@@ -155,4 +155,24 @@ public function it_can_sort_by_two_fields_with_specifying_desc_sort_orders()
155155

156156
$this->assertEquals($expected, multiarray_sort_by($array, 'name', SORT_DESC, 'model', SORT_DESC));
157157
}
158+
159+
/** @test */
160+
public function it_can_sort_by_two_fields_with_specifying_any_sort_orders()
161+
{
162+
$array = [
163+
['name' => 'Mercedes-Benz', 'model' => 'GLS', 'price' => 120000],
164+
['name' => 'Mercedes-Benz', 'model' => 'GLE Coupe', 'price' => 110000],
165+
['name' => 'BMW', 'model' => 'X6', 'price' => 77000],
166+
['name' => 'Porsche', 'model' => 'Cayenne', 'price' => 117000],
167+
];
168+
169+
$expected = [
170+
['name' => 'BMW', 'model' => 'X6', 'price' => 77000],
171+
['name' => 'Mercedes-Benz', 'model' => 'GLS', 'price' => 120000],
172+
['name' => 'Mercedes-Benz', 'model' => 'GLE Coupe', 'price' => 110000],
173+
['name' => 'Porsche', 'model' => 'Cayenne', 'price' => 117000],
174+
];
175+
176+
$this->assertEquals($expected, multiarray_sort_by($array, 'name', SORT_ASC, 'model', SORT_DESC));
177+
}
158178
}

0 commit comments

Comments
 (0)