ViewsRendererTest.php in Entity Print 8.2
File
modules/entity_print_views/tests/src/Kernel/ViewsRendererTest.php
View source
<?php
namespace Drupal\Tests\entity_print_views\Kernel;
use Drupal\entity_print\FilenameGeneratorInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\views\Views;
class ViewsRendererTest extends KernelTestBase {
public static $modules = [
'system',
'user',
'views',
'node',
'filter',
'entity_print',
'entity_print_views',
'entity_print_views_test_views',
];
public function setUp() : void {
parent::setUp();
$this
->installEntitySchema('node');
$this
->installEntitySchema('user');
$this
->installConfig([
'system',
'entity_print_views_test_views',
]);
}
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,
]));
}
}