function StyleSerializerEntityTest::testSerializerViewsUI

Same name in other branches
  1. 11.x core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php \Drupal\Tests\rest\Functional\Views\StyleSerializerEntityTest::testSerializerViewsUI()

Tests the views interface for REST export displays.

File

core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php, line 575

Class

StyleSerializerEntityTest
Tests the serializer style plugin.

Namespace

Drupal\Tests\rest\Functional\Views

Code

public function testSerializerViewsUI() : void {
    $this->drupalLogin($this->adminUser);
    // Click the "Update preview button".
    $this->drupalGet('admin/structure/views/view/test_serializer_display_field/edit/rest_export_1');
    $this->submitForm($edit = [], 'Update preview');
    $this->assertSession()
        ->statusCodeEquals(200);
    // Check if we receive the expected result.
    $result = $this->assertSession()
        ->elementExists('xpath', '//div[@id="views-live-preview"]/pre');
    $json_preview = $result->getText();
    $this->assertSame($json_preview, $this->drupalGet('test/serialize/field', [
        'query' => [
            '_format' => 'json',
        ],
    ]), 'The expected JSON preview output was found.');
}

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