Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / views / tests / src / Unit / Plugin / area / MessagesTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Unit\Plugin\area;
4
5 use Drupal\Tests\UnitTestCase;
6 use Drupal\views\Plugin\views\area\Messages;
7
8 /**
9  * @coversDefaultClass \Drupal\views\Plugin\views\area\Messages
10  * @group views
11  */
12 class MessagesTest extends UnitTestCase {
13
14   /**
15    * The view executable object.
16    *
17    * @var \Drupal\views\ViewExecutable
18    */
19   protected $view;
20
21   /**
22    * The message handler.
23    *
24    * @var \Drupal\views\Plugin\views\area\Messages
25    */
26   protected $messagesHandler;
27
28   /**
29    * {@inheritdoc}
30    */
31   protected function setUp() {
32     parent::setUp();
33
34     $this->messagesHandler = new Messages([], 'result', []);
35   }
36
37   /**
38    * Tests the render method.
39    *
40    * @covers ::defineOptions
41    * @covers ::render
42    */
43   public function testRender() {
44     // The handler is configured to show with empty views by default, so should
45     // appear.
46     $this->assertSame(['#type' => 'status_messages'], $this->messagesHandler->render());
47
48     // Turn empty off, and make sure it isn't rendered.
49     $this->messagesHandler->options['empty'] = FALSE;
50     // $empty parameter passed to render will still be FALSE, so should still
51     // appear.
52     $this->assertSame(['#type' => 'status_messages'], $this->messagesHandler->render());
53     // Should now be empty as both the empty option and parameter are empty.
54     $this->assertSame([], $this->messagesHandler->render(TRUE));
55   }
56
57 }