X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fcomment%2Ftests%2Fsrc%2FFunctional%2FViews%2FCommentRestExportTest.php;fp=web%2Fcore%2Fmodules%2Fcomment%2Ftests%2Fsrc%2FFunctional%2FViews%2FCommentRestExportTest.php;h=17e04b5c5cf775a7cbeb973190a1f5afbd470257;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=0000000000000000000000000000000000000000;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php b/web/core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php new file mode 100644 index 000000000..17e04b5c5 --- /dev/null +++ b/web/core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php @@ -0,0 +1,67 @@ + 0, + 'entity_id' => $this->nodeUserCommented->id(), + 'entity_type' => 'node', + 'field_name' => 'comment', + 'subject' => 'A lot, apparently', + 'cid' => '', + 'pid' => $this->comment->id(), + 'mail' => 'someone@example.com', + 'name' => 'bobby tables', + 'hostname' => 'public.example.com', + ]; + $this->comment = Comment::create($comment); + $this->comment->save(); + + $user = $this->drupalCreateUser(['access comments']); + $this->drupalLogin($user); + } + + + /** + * Test comment row. + */ + public function testCommentRestExport() { + $this->drupalGet(sprintf('node/%d/comments', $this->nodeUserCommented->id()), ['query' => ['_format' => 'hal_json']]); + $this->assertResponse(200); + $contents = Json::decode($this->getRawContent()); + $this->assertEqual($contents[0]['subject'], 'How much wood would a woodchuck chuck'); + $this->assertEqual($contents[1]['subject'], 'A lot, apparently'); + $this->assertEqual(count($contents), 2); + + // 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'); + } + +}