function NodePageVariableDeprecationTest::testPageVariableDeprecation

Tests that deprecations are thrown correctly for the page variable.

File

core/modules/node/tests/src/Functional/NodePageVariableDeprecationTest.php, line 40

Class

NodePageVariableDeprecationTest
Tests page variable deprecation.

Namespace

Drupal\Tests\node\Functional

Code

public function testPageVariableDeprecation() : void {
  // Create a dummy node to skip node--1.html.twig in test_theme.
  $this->drupalCreateNode();
  $node = $this->drupalCreateNode([
    'type' => 'test_page_variable',
  ]);
  $this->expectDeprecation("'page' is deprecated in drupal:11.3.0 and is removed in drupal:13.0.0. Use 'view_mode' instead. See https://www.drupal.org/node/3458593");
  $this->drupalGet($node->toUrl());
  $this->assertSession()
    ->pageTextContains('The page variable is set');
  $build = \Drupal::entityTypeManager()->getViewBuilder('node')
    ->view($node, 'test_page_variable');
  $output = (string) \Drupal::service('renderer')->renderRoot($build);
  $this->assertStringNotContainsString('The page variable is set', $output);
}

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