You are here

public function NodeBlockFunctionalTest::testDeprecatedNodeTypeCondition in Drupal 9

Tests customization of deprecated node type condition.

@group legacy

File

core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php, line 242

Class

NodeBlockFunctionalTest
Tests node block functionality.

Namespace

Drupal\Tests\node\Functional

Code

public function testDeprecatedNodeTypeCondition() {
  $this
    ->expectDeprecation('\\Drupal\\node\\Plugin\\Condition\\NodeType is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \\Drupal\\Core\\Entity\\Plugin\\Condition\\EntityBundle instead. See https://www.drupal.org/node/2983299');
  $this
    ->expectDeprecation("The 'condition.plugin.node_type' config schema is deprecated in drupal:9.3.0 and is removed from drupal 10.0.0. Use the 'entity_bundle:node_type' key instead to define a node type condition. See https://www.drupal.org/node/2983299.");
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalPlaceBlock('system_powered_by_block', [
    'id' => 'powered_by_deprecated',
    'visibility' => [
      'node_type' => [
        'bundles' => [
          'article' => 'article',
        ],
      ],
    ],
    'context_mapping' => [
      'node' => '@node.node_route_context:node',
    ],
  ]);

  // On an existing block with the deprecated plugin, the deprecated
  // label is shown.
  $this
    ->drupalGet("admin/structure/block/manage/powered_by_deprecated");
  $this
    ->assertSession()
    ->pageTextContains('Content type');
  $this
    ->assertSession()
    ->pageTextContains('Content types (Deprecated)');
  $this
    ->submitForm([], 'Save');
}