X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fembed%2Fsrc%2FTests%2FPreviewTest.php;fp=web%2Fmodules%2Fcontrib%2Fembed%2Fsrc%2FTests%2FPreviewTest.php;h=11613ee3e5ebb04c0206b0fad8336cdd2e7738b4;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/embed/src/Tests/PreviewTest.php b/web/modules/contrib/embed/src/Tests/PreviewTest.php new file mode 100644 index 000000000..11613ee3e --- /dev/null +++ b/web/modules/contrib/embed/src/Tests/PreviewTest.php @@ -0,0 +1,66 @@ +getRoute('plain_text'); + $this->assertResponse(200); + $this->assertText(static::SUCCESS); + + // The anonymous user should not have permission to use embed_test format. + $this->getRoute('embed_test'); + $this->assertResponse(403); + + // Now login a user that can use the embed_test format. + $this->drupalLogin($this->webUser); + + $this->getRoute('plain_text'); + $this->assertResponse(200); + $this->assertText(static::SUCCESS); + + $this->getRoute('embed_test'); + $this->assertResponse(200); + $this->assertText(static::SUCCESS); + + // Test preview route with an empty request. + $this->getRoute('embed_test', ''); + $this->assertResponse(404); + + // Test preview route with an invalid text format. + $this->getRoute('invalid_format'); + $this->assertResponse(404); + } + + /** + * Performs a request to the embed.preview route. + * + * @param string $filter_format_id + * ID of the filter format. + * @param string $value + * The query string value to include. + * + * @return string + * The retrieved HTML string. + */ + public function getRoute($filter_format_id, $value = NULL) { + $url = 'embed/preview/' . $filter_format_id; + if (!isset($value)) { + $value = static::SUCCESS; + } + return $this->drupalGet($url, ['query' => ['value' => $value]]); + } + +}