You are here

FileElementTest.php in Drupal 9

Same filename and directory in other branches
  1. 8 core/modules/system/tests/src/Kernel/Form/FileElementTest.php

File

core/modules/system/tests/src/Kernel/Form/FileElementTest.php
View source
<?php

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() {
    $form = $this->container
      ->get('form_builder')
      ->getForm(FormTestFileForm::class);
    $this
      ->assertSame('file', $form['file']['#type']);
    $this
      ->assertTrue($form['file']['#multiple']);
    $this
      ->assertContains('cagatio', $form['file']['#attributes']['class']);
  }

}

Classes

Namesort descending Description
FileElementTest Tests for the 'file' form element.