function StyleSerializerTest::testSharedPagePath

Same name in other branches
  1. 9 core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php \Drupal\Tests\rest\Functional\Views\StyleSerializerTest::testSharedPagePath()
  2. 8.9.x core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php \Drupal\Tests\rest\Functional\Views\StyleSerializerTest::testSharedPagePath()
  3. 10 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 120

Class

StyleSerializerTest
Tests the serializer style plugin.

Namespace

Drupal\Tests\rest\Functional\Views

Code

public function testSharedPagePath() : void {
    // 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');
}

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