You are here

public function DatetimeElementFormTest::testDatetimeElementUntrustedCallbacks in Drupal 9

Same name and namespace in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php \Drupal\KernelTests\Core\Datetime\DatetimeElementFormTest::testDatetimeElementUntrustedCallbacks()

Tests that deprecations are raised if untrusted callbacks are used.

@dataProvider providerUntrusted @group legacy

Parameters

string $date_callback: Name of the callback to use for the date-time date callback.

string $time_callback: Name of the callback to use for the date-time time callback.

string|null $expected_deprecation: The expected deprecation message if a deprecation should be raised, or NULL if otherwise.

File

core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php, line 157

Class

DatetimeElementFormTest
Tests DatetimeElement functionality.

Namespace

Drupal\KernelTests\Core\Datetime

Code

public function testDatetimeElementUntrustedCallbacks(string $date_callback = 'datetimeDateCallbackTrusted', string $time_callback = 'datetimeTimeCallbackTrusted', string $expected_deprecation = NULL) : void {
  $form = \Drupal::formBuilder()
    ->getForm($this, $date_callback, $time_callback);
  if ($expected_deprecation) {
    $this
      ->expectDeprecation($expected_deprecation);
  }
  $this
    ->render($form);
  $this
    ->assertTrue($this->dateCallbackExecuted);
  $this
    ->assertTrue($this->timeCallbackExecuted);
}