3 namespace Drupal\Tests\views\Kernel\Handler;
5 use Drupal\simpletest\BlockCreationTrait;
6 use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
7 use Drupal\views\Views;
10 * Tests the view area handler.
13 * @see \Drupal\views\Plugin\views\area\View
15 class AreaOrderTest extends ViewsKernelTestBase {
17 use BlockCreationTrait;
24 public static $modules = ['user', 'block'];
27 * Views used by this test.
31 public static $testViews = ['test_area_order'];
36 protected function setUpFixtures() {
37 // Install the themes used for this test.
38 $this->container->get('theme_installer')->install(['bartik']);
40 $this->placeBlock('system_branding_block', [
41 'id' => 'bartik_branding',
43 'plugin' => 'system_branding_block',
47 $this->placeBlock('system_powered_by_block', [
48 'id' => 'bartik_powered',
53 parent::setUpFixtures();
57 * Tests the order of the handlers.
59 public function testAreaOrder() {
60 $renderer = $this->container->get('renderer');
61 $view = Views::getView('test_area_order');
62 $renderable = $view->buildRenderable();
63 $output = $this->render($renderable);
65 $position_powered = strpos($output, 'block-bartik-powered');
66 $position_branding = strpos($output, 'block-bartik-branding');
68 $this->assertNotEquals(0, $position_powered, 'ID bartik-powered found.');
69 $this->assertNotEquals(0, $position_branding, 'ID bartik-branding found');
71 // Make sure "powered" is before "branding", so it reflects the position
72 // in the configuration, and not the weight of the blocks.
73 $this->assertTrue($position_powered < $position_branding, 'Block bartik-powered is positioned before block bartik-branding');