class ManagedFileTest
Same name and namespace in other branches
- 10 core/modules/file/tests/src/Kernel/ManagedFileTest.php \Drupal\Tests\file\Kernel\ManagedFileTest
- 11.x core/modules/file/tests/src/Kernel/ManagedFileTest.php \Drupal\Tests\file\Kernel\ManagedFileTest
Managed file element test.
@group file
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\file\Kernel\FileManagedUnitTestBase extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\file\Kernel\ManagedFileTest implements \Drupal\Core\Form\FormInterface extends \Drupal\Tests\file\Kernel\FileManagedUnitTestBase
- class \Drupal\Tests\file\Kernel\FileManagedUnitTestBase extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ManagedFileTest
See also
\Drupal\file\Element\ManagedFile
File
-
core/
modules/ file/ tests/ src/ Kernel/ ManagedFileTest.php, line 16
Namespace
Drupal\Tests\file\KernelView source
class ManagedFileTest extends FileManagedUnitTestBase implements FormInterface {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'form_test_managed_file';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['managed_file'] = [
'#type' => 'managed_file',
];
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
}
/**
* Tests that managed file elements can be programmatically submitted.
*/
public function testManagedFileElement() {
$form_state = new FormState();
$values['managed_file'] = NULL;
$form_state->setValues($values);
$this->container
->get('form_builder')
->submitForm($this, $form_state);
// Should submit without any errors.
$this->assertEquals(0, count($form_state->getErrors()));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.