protected function GraphTest::assertWeights in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/Graph/GraphTest.php \Drupal\Tests\Component\Graph\GraphTest::assertWeights()
- 9 core/tests/Drupal/Tests/Component/Graph/GraphTest.php \Drupal\Tests\Component\Graph\GraphTest::assertWeights()
Verify expected order in a graph.
@internal
Parameters
array $graph: A graph array processed by \Drupal\Component\Graph\Graph::searchAndSort()
array $expected_orders: An array containing lists of vertices in their expected order.
1 call to GraphTest::assertWeights()
- GraphTest::testDepthFirstSearch in core/
tests/ Drupal/ Tests/ Component/ Graph/ GraphTest.php - Tests depth-first-search features.
File
- core/
tests/ Drupal/ Tests/ Component/ Graph/ GraphTest.php, line 175
Class
- GraphTest
- @coversDefaultClass \Drupal\Component\Graph\Graph @group Graph
Namespace
Drupal\Tests\Component\GraphCode
protected function assertWeights(array $graph, array $expected_orders) : void {
foreach ($expected_orders as $order) {
$previous_vertex = array_shift($order);
foreach ($order as $vertex) {
$this
->assertLessThan($graph[$vertex]['weight'], $graph[$previous_vertex]['weight'], sprintf("Weight of vertex %s should be less than vertex %s.", $previous_vertex, $vertex));
}
}
}