public function CommentRestExportTest::testCommentRestExport in Drupal 9
Same name and namespace in other branches
- 8 core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php \Drupal\Tests\comment\Functional\Views\CommentRestExportTest::testCommentRestExport()
Tests comment row.
File
- core/
modules/ comment/ tests/ src/ Functional/ Views/ CommentRestExportTest.php, line 63
Class
- CommentRestExportTest
- Tests a comment rest export view.
Namespace
Drupal\Tests\comment\Functional\ViewsCode
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');
}