FileElementTest.php

Same filename in other branches
  1. 9 core/modules/system/tests/src/Kernel/Form/FileElementTest.php
  2. 8.9.x core/modules/system/tests/src/Kernel/Form/FileElementTest.php
  3. 10 core/modules/system/tests/src/Kernel/Form/FileElementTest.php

Namespace

Drupal\Tests\system\Kernel\Form

File

core/modules/system/tests/src/Kernel/Form/FileElementTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\system\Kernel\Form;

use Drupal\form_test\Form\FormTestFileForm;
use Drupal\KernelTests\KernelTestBase;

/**
 * Tests for the 'file' form element.
 *
 * @group Form
 */
class FileElementTest extends KernelTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'form_test',
    ];
    
    /**
     * Tests that file elements are built and processed correctly.
     */
    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']);
    }

}

Classes

Title Deprecated Summary
FileElementTest Tests for the 'file' form element.

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