You are here

public function StyleSerializerTest::testSharedPagePath in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php \Drupal\Tests\rest\Functional\Views\StyleSerializerTest::testSharedPagePath()
  2. 9 core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php \Drupal\Tests\rest\Functional\Views\StyleSerializerTest::testSharedPagePath()

Verifies REST export views work on the same path as a page display.

File

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

Class

StyleSerializerTest
Tests the serializer style plugin.

Namespace

Drupal\Tests\rest\Functional\Views

Code

public function testSharedPagePath() {

  // Test with no format as well as html explicitly.
  $this
    ->drupalGet('test/serialize/shared');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->responseHeaderEquals('content-type', 'text/html; charset=UTF-8');
  $this
    ->drupalGet('test/serialize/shared', [
    'query' => [
      '_format' => 'html',
    ],
  ]);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->responseHeaderEquals('content-type', 'text/html; charset=UTF-8');
  $this
    ->drupalGet('test/serialize/shared', [
    'query' => [
      '_format' => 'json',
    ],
  ]);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->responseHeaderEquals('content-type', 'application/json');
  $this
    ->drupalGet('test/serialize/shared', [
    'query' => [
      '_format' => 'xml',
    ],
  ]);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->responseHeaderEquals('content-type', 'text/xml; charset=UTF-8');
}