function ToolkitGdTest::testResourceDeprecation
Tests deprecated setResource() and getResource().
@group legacy
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Image/ ToolkitGdTest.php, line 533
Class
- ToolkitGdTest
- Tests for the GD image toolkit.
Namespace
Drupal\KernelTests\Core\ImageCode
public function testResourceDeprecation() : void {
$toolkit = $this->imageFactory
->get()
->getToolkit();
$image = imagecreate(10, 10);
$this->expectDeprecation('Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::setResource() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \\Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::setImage() instead. See https://www.drupal.org/node/3265963');
$toolkit->setResource($image);
$this->expectDeprecation('Checking the \\Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \\Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::image instead. See https://www.drupal.org/node/3265963');
$this->assertTrue(isset($toolkit->resource));
$this->expectDeprecation('Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::getResource() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \\Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::getImage() instead. See https://www.drupal.org/node/3265963');
$this->assertSame($image, $toolkit->getResource());
$this->expectDeprecation('Accessing the \\Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \\Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::image instead. See https://www.drupal.org/node/3265963');
$this->assertSame($image, $toolkit->resource);
$this->expectDeprecation('Setting the \\Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \\Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::image instead. See https://www.drupal.org/node/3265963');
$toolkit->resource = NULL;
$this->assertNull($toolkit->getImage());
$this->expectDeprecation('Unsetting the \\Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::resource property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \\Drupal\\system\\Plugin\\ImageToolkit\\GDToolkit::image instead. See https://www.drupal.org/node/3265963');
$toolkit->setImage($image);
unset($toolkit->resource);
$this->assertNull($toolkit->getImage());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.