function FinderTest::assertRelativeOrder
Asserts that an item in an array comes before another item in that array.
Parameters
array $haystack: The array to examine.
mixed $earlier: The item which should come first.
mixed $later: The item which should come after.
1 call to FinderTest::assertRelativeOrder()
- FinderTest::testFoundDataIsInDependencyOrder in core/
tests/ Drupal/ Tests/ Core/ DefaultContent/ FinderTest.php - Tests that any discovered entity data is sorted into dependency order.
File
-
core/
tests/ Drupal/ Tests/ Core/ DefaultContent/ FinderTest.php, line 63
Class
- FinderTest
- @covers \Drupal\Core\DefaultContent\Finder[[api-linebreak]] @group DefaultContent
Namespace
Drupal\Tests\Core\DefaultContentCode
private function assertRelativeOrder(array $haystack, mixed $earlier, mixed $later) : void {
$haystack = array_values($haystack);
$earlier_index = array_search($earlier, $haystack, TRUE);
$later_index = array_search($later, $haystack, TRUE);
$this->assertIsInt($earlier_index);
$this->assertIsInt($later_index);
// "Later" should be greater than "earlier".
$this->assertGreaterThan($earlier_index, $later_index);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.