AreaOrderTest.php in Drupal 9
File
core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php
View source
<?php
namespace Drupal\Tests\views\Kernel\Handler;
use Drupal\Tests\block\Traits\BlockCreationTrait;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
class AreaOrderTest extends ViewsKernelTestBase {
use BlockCreationTrait;
protected static $modules = [
'user',
'block',
];
public static $testViews = [
'test_area_order',
];
protected function setUpFixtures() {
$this->container
->get('theme_installer')
->install([
'bartik',
]);
$this
->placeBlock('system_branding_block', [
'id' => 'bartik_branding',
'theme' => 'bartik',
'plugin' => 'system_branding_block',
'weight' => 1,
]);
$this
->placeBlock('system_powered_by_block', [
'id' => 'bartik_powered',
'theme' => 'bartik',
'weight' => 2,
]);
parent::setUpFixtures();
}
public function testAreaOrder() {
$view = Views::getView('test_area_order');
$renderable = $view
->buildRenderable();
$output = $this
->render($renderable);
$position_powered = strpos($output, 'block-bartik-powered');
$position_branding = strpos($output, 'block-bartik-branding');
$this
->assertNotEquals(0, $position_powered, 'ID bartik-powered found.');
$this
->assertNotEquals(0, $position_branding, 'ID bartik-branding found');
$this
->assertLessThan($position_branding, $position_powered);
}
}