class ProceduralApiDeprecationTest

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Render/Element/ProceduralApiDeprecationTest.php \Drupal\Tests\Core\Render\Element\ProceduralApiDeprecationTest

Tests the deprecation of global rendering functions.

Attributes

#[Group("Render")] #[Group("legacy")] #[RunTestsInSeparateProcesses] #[IgnoreDeprecations]

Hierarchy

Expanded class hierarchy of ProceduralApiDeprecationTest

File

core/tests/Drupal/Tests/Core/Render/Element/ProceduralApiDeprecationTest.php, line 15

Namespace

Drupal\Tests\Core\Render\Element
View source
class ProceduralApiDeprecationTest extends UnitTestCase {
  
  /**
   * {@inheritdoc}
   */
  public function setUp() : void {
    parent::setUp();
    include_once $this->root . '/core/includes/common.inc';
  }
  
  /**
   * Tests the deprecation of the global hide() function.
   */
  public function testHideDeprecation() : void {
    $element = [];
    $this->expectUserDeprecationMessage("The global hide() function is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. To hide form elements, use ['#access'] = FALSE. For render elements, use ['#printed'] = TRUE. See https://www.drupal.org/node/3261271");
    $this->assertEquals([
      '#printed' => TRUE,
    ], hide($element));
  }
  
  /**
   * Tests the deprecation of the global show() function.
   */
  public function testShowDeprecation() : void {
    $element = [];
    $this->expectUserDeprecationMessage("The global show() function is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. To show form elements, use ['#access'] = TRUE. For render elements, use ['#printed'] = FALSE. See https://www.drupal.org/node/3261271");
    $this->assertEquals([
      '#printed' => FALSE,
    ], show($element));
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DrupalTestCaseTrait::$root protected property The Drupal root directory.
DrupalTestCaseTrait::checkErrorHandlerOnTearDown public function Checks the test error handler after test execution. 1
DrupalTestCaseTrait::getDrupalRoot protected static function Returns the Drupal root directory. 1
DrupalTestCaseTrait::setDebugDumpHandler public static function Registers the dumper CLI handler when the DebugDump extension is enabled.
ProceduralApiDeprecationTest::setUp public function Overrides UnitTestCase::setUp
ProceduralApiDeprecationTest::testHideDeprecation public function Tests the deprecation of the global hide() function.
ProceduralApiDeprecationTest::testShowDeprecation public function Tests the deprecation of the global show() function.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::setupMockIterator protected function Set up a traversable class mock to return specific items when iterated.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.