Version 1
[yaffs-website] / web / core / modules / views / tests / src / Functional / Handler / AreaHTTPStatusCodeTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Functional\Handler;
4
5 use Drupal\Tests\views\Functional\ViewTestBase;
6 use Drupal\views\Views;
7
8 /**
9  * Tests the http_status_code area handler.
10  *
11  * @group views
12  * @see \Drupal\views\Plugin\views\area\HTTPStatusCode
13  */
14 class AreaHTTPStatusCodeTest extends ViewTestBase {
15
16   /**
17    * Views used by this test.
18    *
19    * @var array
20    */
21   public static $testViews = ['test_http_status_code'];
22
23   /**
24    * Modules to enable.
25    *
26    * @var array
27    */
28   public static $modules = ['node'];
29
30   /**
31    * Tests the area handler.
32    */
33   public function testHTTPStatusCodeHandler() {
34     $this->drupalGet('test-http-status-code');
35     $this->assertResponse(200);
36
37     // Change the HTTP status code to 418.
38     $view = Views::getView('test_http_status_code');
39     $display = &$view->storage->getDisplay('default');
40     $display['display_options']['empty']['http_status_code']['status_code'] = 418;
41     $view->save();
42
43     // Test that the HTTP response is "I'm a teapot".
44     $this->drupalGet('test-http-status-code');
45     $this->assertResponse(418);
46   }
47
48 }