function CommentHalExportTest::testCommentRestExport

Tests comment row.

File

core/modules/hal/tests/src/Functional/comment/Views/CommentHalExportTest.php, line 68

Class

CommentHalExportTest
Tests a comment rest export view.

Namespace

Drupal\Tests\hal\Functional\comment\Views

Code

public function testCommentRestExport() {
    $this->drupalGet(sprintf('node/%d/comments', $this->nodeUserCommented
        ->id()), [
        'query' => [
            '_format' => 'hal_json',
        ],
    ]);
    $this->assertSession()
        ->statusCodeEquals(200);
    $contents = Json::decode($this->getSession()
        ->getPage()
        ->getContent());
    $this->assertEquals('How much wood would a woodchuck chuck', $contents[0]['subject']);
    $this->assertEquals('A lot, apparently', $contents[1]['subject']);
    $this->assertCount(2, $contents);
    // Ensure field-level access is respected - user shouldn't be able to see
    // mail or hostname fields.
    $this->assertSession()
        ->responseNotContains('someone@example.com');
    $this->assertSession()
        ->responseNotContains('public.example.com');
}

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