function FileElementTest::testFileElement

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Kernel/Form/FileElementTest.php \Drupal\Tests\system\Kernel\Form\FileElementTest::testFileElement()
  2. 8.9.x core/modules/system/tests/src/Kernel/Form/FileElementTest.php \Drupal\Tests\system\Kernel\Form\FileElementTest::testFileElement()
  3. 11.x core/modules/system/tests/src/Kernel/Form/FileElementTest.php \Drupal\Tests\system\Kernel\Form\FileElementTest::testFileElement()

Tests that file elements are built and processed correctly.

File

core/modules/system/tests/src/Kernel/Form/FileElementTest.php, line 25

Class

FileElementTest
Tests for the 'file' form element.

Namespace

Drupal\Tests\system\Kernel\Form

Code

public function testFileElement() : void {
  $form = $this->container
    ->get('form_builder')
    ->getForm(FormTestFileForm::class);
  $this->assertSame('file', $form['file']['#type']);
  $this->assertTrue($form['file']['#multiple']);
  $this->assertContains('some-class', $form['file']['#attributes']['class']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.