function FormErrorHandlerFileUploadTest::setUp
Same name in other branches
- 9 core/modules/inline_form_errors/tests/src/Functional/FormErrorHandlerFileUploadTest.php \Drupal\Tests\inline_form_errors\Functional\FormErrorHandlerFileUploadTest::setUp()
- 8.9.x core/modules/inline_form_errors/tests/src/Functional/FormErrorHandlerFileUploadTest.php \Drupal\Tests\inline_form_errors\Functional\FormErrorHandlerFileUploadTest::setUp()
- 10 core/modules/inline_form_errors/tests/src/Functional/FormErrorHandlerFileUploadTest.php \Drupal\Tests\inline_form_errors\Functional\FormErrorHandlerFileUploadTest::setUp()
Overrides BrowserTestBase::setUp
File
-
core/
modules/ inline_form_errors/ tests/ src/ Functional/ FormErrorHandlerFileUploadTest.php, line 39
Class
- FormErrorHandlerFileUploadTest
- Tests file upload scenario's with Inline Form Errors.
Namespace
Drupal\Tests\inline_form_errors\FunctionalCode
protected function setUp() : void {
parent::setUp();
// Create a node type for testing.
NodeType::create([
'type' => 'page',
'name' => 'page',
])->save();
// Add a file field.
FieldStorageConfig::create([
'entity_type' => 'node',
'field_name' => 'field_ief_file',
'type' => 'file',
'cardinality' => 1,
])->save();
FieldConfig::create([
'field_name' => 'field_ief_file',
'label' => 'field_ief_file',
'entity_type' => 'node',
'bundle' => 'page',
'required' => TRUE,
'settings' => [
'file_extensions' => 'png gif jpg jpeg webp',
],
])->save();
EntityFormDisplay::create([
'targetEntityType' => 'node',
'bundle' => 'page',
'mode' => 'default',
'status' => TRUE,
])->setComponent('field_ief_file', [
'type' => 'file_generic',
'settings' => [],
])
->save();
EntityViewDisplay::create([
'targetEntityType' => 'node',
'bundle' => 'page',
'mode' => 'default',
'status' => TRUE,
'label' => 'hidden',
'type' => 'file_default',
])->save();
// Create and login a user.
$account = $this->drupalCreateUser([
'access content',
'access administration pages',
'administer nodes',
'create page content',
]);
$this->drupalLogin($account);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.