You are here

public function ViewsRendererTest::testGenerateFilename in Entity Print 8.2

Test filename generation for the views renderer.

File

modules/entity_print_views/tests/src/Kernel/ViewsRendererTest.php, line 45

Class

ViewsRendererTest
Views renderer test.

Namespace

Drupal\Tests\entity_print_views\Kernel

Code

public function testGenerateFilename() {
  $view = Views::getView('my_test_view');
  $view
    ->setDisplay('page_1');
  $renderer = $this->container
    ->get('entity_type.manager')
    ->getHandler('view', 'entity_print');
  $this
    ->assertSame('My Test view', $renderer
    ->getFilename([
    $view->storage,
  ]));
  $view = Views::getView('my_test_view');
  $view
    ->setDisplay('block_1');
  $renderer = $this->container
    ->get('entity_type.manager')
    ->getHandler('view', 'entity_print');
  $this
    ->assertSame('My Test view block', $renderer
    ->getFilename([
    $view->storage,
  ]));
  $view
    ->setTitle(' ');
  $this
    ->assertSame(FilenameGeneratorInterface::DEFAULT_FILENAME, $renderer
    ->getFilename([
    $view->storage,
  ]));
}