function DatetimeElementFormTest::testDatetimeElementUntrustedCallbacks

Same name in other branches
  1. 9 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_exception: The expected exception message if an exception should be thrown, or NULL if otherwise.

File

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

Class

DatetimeElementFormTest
Tests DatetimeElement functionality.

Namespace

Drupal\KernelTests\Core\Datetime

Code

public function testDatetimeElementUntrustedCallbacks(string $date_callback = 'datetimeDateCallbackTrusted', string $time_callback = 'datetimeTimeCallbackTrusted', ?string $expected_exception = NULL) : void {
    if ($expected_exception) {
        $this->expectException(UntrustedCallbackException::class);
        $this->expectExceptionMessage($expected_exception);
    }
    $form = \Drupal::formBuilder()->getForm($this, $date_callback, $time_callback);
    $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.