You are here

class TokenTest in Drupal 10

Same name in this branch
  1. 10 core/tests/Drupal/Tests/Core/Utility/TokenTest.php \Drupal\Tests\Core\Utility\TokenTest
  2. 10 core/tests/Drupal/Tests/Core/Render/Element/TokenTest.php \Drupal\Tests\Core\Render\Element\TokenTest
Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Render/Element/TokenTest.php \Drupal\Tests\Core\Render\Element\TokenTest
  2. 9 core/tests/Drupal/Tests/Core/Render/Element/TokenTest.php \Drupal\Tests\Core\Render\Element\TokenTest

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

Hierarchy

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

Expanded class hierarchy of TokenTest

File

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

Namespace

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

  /**
   * @covers ::valueCallback
   *
   * @dataProvider providerTestValueCallback
   */
  public function testValueCallback($expected, $input) {
    $element = [];
    $form_state = $this
      ->prophesize(FormStateInterface::class)
      ->reveal();
    $this
      ->assertSame($expected, Token::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,
    ];
    return $data;
  }

}

Members