function ThemeRegionTest::testLegacyRegionListing
Same name and namespace in other branches
- main core/tests/Drupal/KernelTests/Core/Theme/ThemeRegionTest.php \Drupal\KernelTests\Core\Theme\ThemeRegionTest::testLegacyRegionListing()
Tests listing a theme's regions using legacy functions.
Attributes
#[IgnoreDeprecations]
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Theme/ ThemeRegionTest.php, line 51
Class
- ThemeRegionTest
- Tests theme region listing.
Namespace
Drupal\KernelTests\Core\ThemeCode
public function testLegacyRegionListing() : void {
$this->expectUserDeprecationMessage("system_region_list() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service('theme_handler')->getTheme()->listAllRegions() or \\Drupal::service('theme_handler')->getTheme()->listVisibleRegions() instead. See https://www.drupal.org/node/3015925");
$this->expectUserDeprecationMessage("system_default_region() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service('theme_handler')->getTheme()->getDefaultRegion() instead. See https://www.drupal.org/node/3015925");
$all_regions = system_region_list('stark', REGIONS_ALL);
$visible_regions = system_region_list('stark', REGIONS_VISIBLE);
// There's no theme installed.
$this->assertEmpty($all_regions);
$this->assertEmpty($visible_regions);
$this->assertEquals('', system_default_region('stark'));
// Install Stark.
$this->container
->get('theme_installer')
->install([
'stark',
]);
$all_regions = system_region_list('stark', REGIONS_ALL);
$visible_regions = system_region_list('stark', REGIONS_VISIBLE);
$this->assertArrayHasKey('page_top', $all_regions);
$this->assertArrayHasKey('sidebar_first', $all_regions);
$this->assertArrayNotHasKey('page_top', $visible_regions);
$this->assertArrayHasKey('sidebar_first', $visible_regions);
$this->assertEquals('sidebar_first', system_default_region('stark'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.