public function RendererTest::testRenderSortingWithSetHashSorted in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderSortingWithSetHashSorted()
- 10 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderSortingWithSetHashSorted()
@covers ::render @covers ::doRender
File
- core/
tests/ Drupal/ Tests/ Core/ Render/ RendererTest.php, line 507 - Contains \Drupal\Tests\Core\Render\RendererTest.
Class
- RendererTest
- @coversDefaultClass \Drupal\Core\Render\Renderer @group Render
Namespace
Drupal\Tests\Core\RenderCode
public function testRenderSortingWithSetHashSorted() {
$first = $this
->randomMachineName();
$second = $this
->randomMachineName();
// The same array structure again, but with #sorted set to TRUE.
$elements = [
'second' => [
'#weight' => 10,
'#markup' => $second,
],
'first' => [
'#weight' => 0,
'#markup' => $first,
],
'#sorted' => TRUE,
];
$output = $this->renderer
->renderRoot($elements);
// The elements should appear in output in the same order as the array.
$this
->assertTrue(strpos($output, $second) < strpos($output, $first), 'Elements were not sorted.');
}