$entity_type =
$this->
createMock('Drupal\Core\Entity\EntityTypeInterface'
);
$entity_type->
expects($this->
any()) ->
method('getClass'
) ->
willReturn('Drupal\Tests\search\Unit\TestSearchPage'
);
$this->storage->
expects($this->
once()) ->
method('getEntityType'
) ->
willReturn($entity_type);
// 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);
}}