TextfieldTest.php

Same filename in this branch
  1. 10 core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php
  2. 10 core/modules/text/tests/src/Unit/Plugin/migrate/field/d7/TextFieldTest.php
  3. 10 core/modules/text/tests/src/Functional/TextFieldTest.php
Same filename and directory in other branches
  1. 9 core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php
  2. 9 core/modules/text/tests/src/Unit/Migrate/d7/TextFieldTest.php
  3. 9 core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php
  4. 9 core/modules/text/tests/src/Unit/Plugin/migrate/field/d7/TextFieldTest.php
  5. 9 core/modules/text/tests/src/Functional/TextFieldTest.php
  6. 9 core/tests/Drupal/Tests/Core/Render/Element/TextfieldTest.php
  7. 8.9.x core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php
  8. 8.9.x core/modules/text/tests/src/Unit/Migrate/d7/TextFieldTest.php
  9. 8.9.x core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php
  10. 8.9.x core/modules/text/tests/src/Unit/Plugin/migrate/field/d7/TextFieldTest.php
  11. 8.9.x core/modules/text/tests/src/Functional/TextFieldTest.php
  12. 8.9.x core/tests/Drupal/Tests/Core/Render/Element/TextfieldTest.php
  13. 11.x core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php
  14. 11.x core/modules/text/tests/src/Unit/Plugin/migrate/field/d7/TextFieldTest.php
  15. 11.x core/modules/text/tests/src/Functional/TextFieldTest.php
  16. 11.x core/tests/Drupal/Tests/Core/Render/Element/TextfieldTest.php

Namespace

Drupal\Tests\Core\Render\Element

File

core/tests/Drupal/Tests/Core/Render/Element/TextfieldTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\Core\Render\Element;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\Textfield;
use Drupal\Tests\UnitTestCase;

/**
 * @coversDefaultClass \Drupal\Core\Render\Element\Textfield
 * @group Render
 */
class TextfieldTest extends UnitTestCase {
  
  /**
   * @covers ::valueCallback
   *
   * @dataProvider providerTestValueCallback
   */
  public function testValueCallback($expected, $input) : void {
    $element = [];
    $form_state = $this->prophesize(FormStateInterface::class)
      ->reveal();
    $this->assertSame($expected, Textfield::valueCallback($element, $input, $form_state));
  }
  
  /**
   * Data provider for testValueCallback().
   */
  public static function providerTestValueCallback() {
    $data = [];
    $data[] = [
      NULL,
      FALSE,
    ];
    $data[] = [
      NULL,
      NULL,
    ];
    $data[] = [
      '',
      [
        'test',
      ],
    ];
    $data[] = [
      'test',
      'test',
    ];
    $data[] = [
      '123',
      123,
    ];
    $data[] = [
      'testWithNewline',
      "test\nWith\rNewline",
    ];
    return $data;
  }

}

Classes

Title Deprecated Summary
TextfieldTest @coversDefaultClass \Drupal\Core\Render\Element\Textfield[[api-linebreak]] @group Render

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