public function FileLinkWidgetTest::testFileLinkWidget in File Link 2.0.x
Tests the widget with the locked languages.
File
- tests/
src/ Kernel/ FileLinkWidgetTest.php, line 42
Class
- FileLinkWidgetTest
- Tests the "file_link" widget
Namespace
Drupal\Tests\file_link\FunctionalCode
public function testFileLinkWidget() {
$storage = $this->container
->get('entity_type.manager')
->getStorage('entity_form_display');
$entityFormDisplay = $storage
->create([
'targetEntityType' => 'entity_test',
'bundle' => 'article',
'mode' => 'default',
'status' => TRUE,
]);
$entityFormDisplay
->setComponent('url_without_extension', [
'type' => 'file_link_default',
'settings' => [
'placeholder_url' => 'http://example.com',
'placeholder_title' => 'The placeholder',
],
])
->save();
$entity = EntityTest::create([
'name' => $this
->randomString(),
'type' => 'article',
'url_without_extension' => [
'uri' => 'http://example.com/file.png',
'format' => 'image/png',
'size' => 1000,
],
]);
$form = $this->container
->get('entity.form_builder')
->getForm($entity);
$widget = $form['url_without_extension']['widget'][0];
$this
->assertEquals('url', $widget['uri']['#type']);
$this
->assertFalse(isset($widget['uri']['#target_type']));
$this
->assertFalse(isset($widget['uri']['#attributes']['data-autocomplete-first-character-blacklist']));
$this
->assertFalse(isset($widget['uri']['#process_default_value']));
$this
->assertEquals(1000, $widget['size']['#value']);
$this
->assertEquals('image/png', $widget['format']['#value']);
}