public function PostRenderSubscriberTest::testEventSubscriber in Entity Print 8.2
Test the event subscriber.
File
- tests/
src/ Kernel/ PostRenderSubscriberTest.php, line 24
Class
- PostRenderSubscriberTest
- @coversDefaultClass \Drupal\entity_print\EventSubscriber\PostRenderSubscriber @group entity_print
Namespace
Drupal\Tests\entity_print\KernelCode
public function testEventSubscriber() {
/** @var \Drupal\Core\Config\ConfigFactoryInterface $configFactory */
$configFactory = $this->container
->get('config.factory');
$event = new PrintHtmlAlterTestEvent();
$subscriber = new PostRenderSubscriber($configFactory, $this->container
->get('request_stack'));
$subscriber
->postRender($event);
// Now change the select PDF engine to phpwkhtmltopdf so we get the
// exception.
$config = $configFactory
->getEditable('entity_print.settings');
$data = $config
->get('print_engines');
$data['pdf_engine'] = 'phpwkhtmltopdf';
$config
->set('print_engines', $data);
$config
->save();
// Try render again and we should get the exception.
$this
->expectException('\\Drupal\\entity_print\\PrintEngineException');
$subscriber
->postRender($event);
}