Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / views / tests / src / Kernel / Handler / AreaOrderTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Kernel\Handler;
4
5 use Drupal\simpletest\BlockCreationTrait;
6 use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
7 use Drupal\views\Views;
8
9 /**
10  * Tests the view area handler.
11  *
12  * @group views
13  * @see \Drupal\views\Plugin\views\area\View
14  */
15 class AreaOrderTest extends ViewsKernelTestBase {
16
17   use BlockCreationTrait;
18
19   /**
20    * Modules to enable.
21    *
22    * @var array
23    */
24   public static $modules = ['user', 'block'];
25
26   /**
27    * Views used by this test.
28    *
29    * @var array
30    */
31   public static $testViews = ['test_area_order'];
32
33   /**
34    * {@inheritdoc}
35    */
36   protected function setUpFixtures() {
37     // Install the themes used for this test.
38     $this->container->get('theme_installer')->install(['bartik']);
39
40     $this->placeBlock('system_branding_block', [
41       'id' => 'bartik_branding',
42       'theme' => 'bartik',
43       'plugin' => 'system_branding_block',
44       'weight' => 1,
45     ]);
46
47     $this->placeBlock('system_powered_by_block', [
48       'id' => 'bartik_powered',
49       'theme' => 'bartik',
50       'weight' => 2,
51     ]);
52
53     parent::setUpFixtures();
54   }
55
56   /**
57    * Tests the order of the handlers.
58    */
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);
64
65     $position_powered = strpos($output, 'block-bartik-powered');
66     $position_branding = strpos($output, 'block-bartik-branding');
67
68     $this->assertNotEquals(0, $position_powered, 'ID bartik-powered found.');
69     $this->assertNotEquals(0, $position_branding, 'ID bartik-branding found');
70
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');
74   }
75
76 }