You are here

public function CommentRestExportTest::testCommentRestExport in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php \Drupal\Tests\comment\Functional\Views\CommentRestExportTest::testCommentRestExport()

Test 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\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
    ->assertEqual($contents[0]['subject'], 'How much wood would a woodchuck chuck');
  $this
    ->assertEqual($contents[1]['subject'], 'A lot, apparently');
  $this
    ->assertCount(2, $contents);

  // Ensure field-level access is respected - user shouldn't be able to see
  // mail or hostname fields.
  $this
    ->assertNoText('someone@example.com');
  $this
    ->assertNoText('public.example.com');
}