function StyleSerializerTest::testSiteMaintenance

Same name in other branches
  1. 9 core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php \Drupal\Tests\rest\Functional\Views\StyleSerializerTest::testSiteMaintenance()
  2. 10 core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php \Drupal\Tests\rest\Functional\Views\StyleSerializerTest::testSiteMaintenance()
  3. 11.x core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php \Drupal\Tests\rest\Functional\Views\StyleSerializerTest::testSiteMaintenance()

Verifies site maintenance mode functionality.

File

core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php, line 265

Class

StyleSerializerTest
Tests the serializer style plugin.

Namespace

Drupal\Tests\rest\Functional\Views

Code

public function testSiteMaintenance() {
    $view = Views::getView('test_serializer_display_field');
    $view->initDisplay();
    $this->executeView($view);
    // Set the site to maintenance mode.
    $this->container
        ->get('state')
        ->set('system.maintenance_mode', TRUE);
    $this->drupalGet('test/serialize/entity', [
        'query' => [
            '_format' => 'json',
        ],
    ]);
    // Verify that the endpoint is unavailable for anonymous users.
    $this->assertSession()
        ->statusCodeEquals(503);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.