protected function SvgFormatterTest::setUp in SVG Formatter 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ SvgFormatterTest.php, line 66
Class
- SvgFormatterTest
- Simple test to ensure that basic functionality of the module works.
Namespace
Drupal\Tests\svg_formatter\FunctionalCode
protected function setUp() {
parent::setUp();
// Create bundle and modify form display.
$this->defaultMediaType = $this
->createMediaType('file', [
'id' => 'svg',
'label' => 'SVG',
]);
$this->defaultSourceField = $this->defaultMediaType
->getSource()
->getSourceFieldDefinition($this->defaultMediaType);
$field_config = FieldConfig::load('media.svg.field_media_file');
$settings = $field_config
->getSettings();
$settings['file_extensions'] = 'svg';
$field_config
->set('settings', $settings);
$field_config
->save();
$display_config = [
'targetEntityType' => 'media',
'bundle' => 'svg',
'mode' => 'default',
'status' => TRUE,
];
$display = $this->container
->get('entity_type.manager')
->getStorage('entity_view_display')
->create($display_config);
$display
->setComponent('field_media_file', [
'label' => 'above',
'type' => 'svg_formatter',
'settings' => [
'inline' => FALSE,
'sanitize' => TRUE,
'apply_dimensions' => TRUE,
'width' => 100,
'height' => 100,
'enable_alt' => TRUE,
'alt_string' => '',
'enable_title' => TRUE,
'title_string' => '',
],
])
->save();
// Enable the media/{media} route.
$media_settings = $this->container
->get('config.factory')
->getEditable('media.settings');
$media_settings
->set('standalone_url', TRUE)
->save();
$this->container
->get('router.builder')
->rebuild();
}