public function PreviewTest::testPreviewRoute in Embed 8
Tests the route used for generating preview of embedding entities.
File
- tests/
src/ Functional/ PreviewTest.php, line 22
Class
- PreviewTest
- Tests the preview controller and route.
Namespace
Drupal\Tests\embed\FunctionalCode
public function testPreviewRoute() {
// Ensure the default filter can be previewed by the anonymous user.
$this
->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);
}