You are here

public function StyleSerializerTest::testSiteMaintenance in Drupal 9

Same name and namespace in other branches
  1. 8 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);
}