You are here

class TextfieldTest in Drupal 10

Same name in this branch
  1. 10 core/modules/text/tests/src/Functional/TextFieldTest.php \Drupal\Tests\text\Functional\TextFieldTest
  2. 10 core/tests/Drupal/Tests/Core/Render/Element/TextfieldTest.php \Drupal\Tests\Core\Render\Element\TextfieldTest
  3. 10 core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php \Drupal\Tests\text\Unit\Migrate\d6\TextFieldTest
  4. 10 core/modules/text/tests/src/Unit/Migrate/d7/TextFieldTest.php \Drupal\Tests\text\Unit\Migrate\d7\TextFieldTest
  5. 10 core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php \Drupal\Tests\text\Unit\Plugin\migrate\field\d6\TextFieldTest
  6. 10 core/modules/text/tests/src/Unit/Plugin/migrate/field/d7/TextFieldTest.php \Drupal\Tests\text\Unit\Plugin\migrate\field\d7\TextFieldTest
Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Render/Element/TextfieldTest.php \Drupal\Tests\Core\Render\Element\TextfieldTest
  2. 9 core/tests/Drupal/Tests/Core/Render/Element/TextfieldTest.php \Drupal\Tests\Core\Render\Element\TextfieldTest

@coversDefaultClass \Drupal\Core\Render\Element\Textfield @group Render

Hierarchy

  • class \Drupal\Tests\Core\Render\Element\TextfieldTest extends \Drupal\Tests\UnitTestCase

Expanded class hierarchy of TextfieldTest

File

core/tests/Drupal/Tests/Core/Render/Element/TextfieldTest.php, line 13

Namespace

Drupal\Tests\Core\Render\Element
View source
class TextfieldTest extends UnitTestCase {

  /**
   * @covers ::valueCallback
   *
   * @dataProvider providerTestValueCallback
   */
  public function testValueCallback($expected, $input) {
    $element = [];
    $form_state = $this
      ->prophesize(FormStateInterface::class)
      ->reveal();
    $this
      ->assertSame($expected, Textfield::valueCallback($element, $input, $form_state));
  }

  /**
   * Data provider for testValueCallback().
   */
  public function providerTestValueCallback() {
    $data = [];
    $data[] = [
      NULL,
      FALSE,
    ];
    $data[] = [
      NULL,
      NULL,
    ];
    $data[] = [
      '',
      [
        'test',
      ],
    ];
    $data[] = [
      'test',
      'test',
    ];
    $data[] = [
      '123',
      123,
    ];
    $data[] = [
      'testwithnewline',
      "test\nwith\rnewline",
    ];
    return $data;
  }

}

Members