function ViewsTest::testPluginManagerDeprecation
Tests the ::pluginManager() deprecation.
Attributes
#[Group('legacy')]
File
-
core/
modules/ views/ tests/ src/ Unit/ ViewsTest.php, line 238
Class
- ViewsTest
- Tests Drupal\views\Views.
Namespace
Drupal\Tests\views\UnitCode
public function testPluginManagerDeprecation() : void {
$this->expectDeprecation('Drupal\\views\\Views::pluginManager() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service(\'plugin.manager.views.{type}\') for specific plugin types or \\Drupal::service(\'views.plugin_managers\')->get($type) for dynamic types. See https://www.drupal.org/node/3566982');
$plugin_manager = $this->createMock(ViewsPluginManager::class);
$locator = $this->createMock(ServiceLocator::class);
$locator->expects($this->once())
->method('get')
->with('display')
->willReturn($plugin_manager);
$this->container
->set('views.plugin_managers', $locator);
// @phpstan-ignore staticMethod.deprecated
$result = Views::pluginManager('display');
$this->assertSame($plugin_manager, $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.