// Declare entities out of their expected order so we can be sure they were
// sorted. We cannot mock these because of uasort(), see
// https://bugs.php.net/bug.php?id=50688.
$unsorted_entities['test4'
] =
new TestSearchPage(['weight' => 0, 'status' => FALSE, 'label' => 'Test4'
]);
$unsorted_entities['test3'
] =
new TestSearchPage(['weight' => 10, 'status' => TRUE, 'label' => 'Test3'
]);
$unsorted_entities['test2'
] =
new TestSearchPage(['weight' => 0, 'status' => TRUE, 'label' => 'Test2'
]);
$unsorted_entities['test1'
] =
new TestSearchPage(['weight' => 0, 'status' => TRUE, 'label' => 'Test1'
]);
$expected =
$unsorted_entities;
ksort($expected);
$sorted_entities =
$this->searchPageRepository->
sortSearchPages($unsorted_entities);
$this->
assertSame($expected,
$sorted_entities);
}}class TestSearchPage extends SearchPage
{ public function __construct(array
$values) { foreach ($values as $key =>
$value) { $this->
$key =
$value;
} }