WebformElementManagedFilePublicTest.php in Webform 6.x
File
tests/src/Functional/Element/WebformElementManagedFilePublicTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
class WebformElementManagedFilePublicTest extends WebformElementBrowserTestBase {
protected static $testWebforms = [
'test_element_managed_file',
];
public static $modules = [
'file',
'webform',
'webform_ui',
];
protected function setUp() {
parent::setUp();
$settings_config = \Drupal::configFactory()
->getEditable('webform.settings');
$settings_config
->set('file.file_public', TRUE);
$settings_config
->save();
}
public function testPublicUpload() {
$requirements = webform_requirements('runtime');
$this
->assertEqual($requirements['webform_file_private']['value'], (string) 'Private file system is set.');
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('/admin/structure/webform/manage/test_element_managed_file/element/managed_file_single/edit');
$this
->assertRaw('Public files upload destination is dangerous for webforms that are available to anonymous and/or untrusted users.');
$this
->assertFieldById('edit-properties-uri-scheme-public', NULL);
\Drupal::configFactory()
->getEditable('webform.settings')
->set('file.file_public', FALSE)
->save();
$this
->drupalGet('/admin/structure/webform/manage/test_element_managed_file/element/managed_file_single/edit');
$this
->assertNoRaw('Public files upload destination is dangerous for webforms that are available to anonymous and/or untrusted users.');
$this
->assertNoFieldById('edit-properties-uri-scheme-public', NULL);
$this
->drupalGet('/admin/structure/webform/manage/test_element_managed_file/element/add');
$this
->assertRaw('>File<');
\Drupal::configFactory()
->getEditable('webform.settings')
->set('element.excluded_elements.managed_file', 'managed_file')
->save();
$this
->drupalGet('/admin/structure/webform/manage/test_element_managed_file/element/add');
$this
->assertNoRaw('>File<');
$this
->drupalGet('/admin/structure/webform/manage/test_element_managed_file');
$this
->assertRaw('<em class="placeholder">managed_file_single</em> is a <em class="placeholder">File</em> element, which has been disabled and will not be rendered.');
$this
->assertRaw('<em class="placeholder">managed_file_multiple</em> is a <em class="placeholder">File</em> element, which has been disabled and will not be rendered.');
}
}