function DatetimeElementFormTest::testDatetimeElementUntrustedCallbacks

Same name and namespace in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php \Drupal\KernelTests\Core\Datetime\DatetimeElementFormTest::testDatetimeElementUntrustedCallbacks()
  2. 11.x 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 159

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($form['datetime_element']['datetimeDateCallbackExecuted']['#value']);
    $this->assertTrue($form['datetime_element']['timeCallbackExecuted']['#value']);
}

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