function ManagedFileTest::testManagedFileElementUntrustedCallbacks
Tests that deprecations are triggered if untrusted callbacks are used.
Attributes
#[IgnoreDeprecations]
File
-
core/
modules/ file/ tests/ src/ Kernel/ ManagedFileTest.php, line 98
Class
- ManagedFileTest
- Managed file element test.
Namespace
Drupal\Tests\file\KernelCode
public function testManagedFileElementUntrustedCallbacks() : void {
$this->expectUserDeprecationMessage(sprintf('Using ManagedFile element #file_value_callbacks callbacks that are not tagged with the %s attribute, not methods of a class that implements %s, and not anonymous functions is deprecated in drupal:12.1.0 and will throw an exception in drupal:13.0.0. The callback was %s. See https://www.drupal.org/node/3620771', TrustedCallback::class, TrustedCallbackInterface::class, Variable::callableToString([
$this,
'managedFileValueCallback',
])));
$form_state = $this->submitManagedFileForm('managedFileValueCallback');
// Untrusted callbacks are still executed during the deprecation period.
$this->assertTrue($form_state->get('managedFileValueCallbackExecuted'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.