EntityPrintTest.php in Entity Print 8.2
File
tests/src/Functional/EntityPrintTest.php
View source
<?php
namespace Drupal\Tests\entity_print\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\user\Entity\Role;
class EntityPrintTest extends BrowserTestBase {
public static $modules = [
'user',
'node',
'entity_print_test',
'entity_print_views',
'entity_print_views_test_views',
];
protected $defaultTheme = 'stark';
protected $node;
public function setUp() : void {
parent::setUp();
$this
->createContentType([
'type' => 'page',
]);
$this->node = $this
->createNode();
$config = $this->container
->get('config.factory')
->getEditable('entity_print.settings');
$config
->set('print_engines.pdf_engine', 'print_exception_engine')
->save();
user_role_grant_permissions(Role::ANONYMOUS_ID, [
'access content',
'bypass entity print access',
'entity print views access',
'administer nodes',
]);
}
public function testExceptionOnRender() {
$this
->drupalGet('/entityprint/pdf/node/1');
$this
->assertSession()
->elementContains('css', '[aria-label="Error message"]', 'Error generating document: Exception thrown by PrintExceptionEngine');
$this
->assertSession()
->pageTextNotContains('The website encountered an unexpected error');
}
public function testViewsExceptionOnRender() {
$this
->drupalGet('/my-test-view');
$this
->clickLink('View PDF');
$this
->assertSession()
->elementContains('css', '[aria-label="Error message"]', 'Error generating document: Exception thrown by PrintExceptionEngine');
$this
->assertSession()
->pageTextNotContains('The website encountered an unexpected error');
}
}