You are here

public function DeprecatedModerationStateViewsRelationshipTest::testReportDeprecatedModerationStateRelationships in Drupal 8

Test how the deprecated relationships appear in the UI.

File

core/modules/content_moderation/tests/src/Functional/DeprecatedModerationStateViewsRelationshipTest.php, line 49

Class

DeprecatedModerationStateViewsRelationshipTest
Test the deprecated views relationships.

Namespace

Drupal\Tests\content_moderation\Functional

Code

public function testReportDeprecatedModerationStateRelationships() {

  // Assert there is a warning in the UI to prevent new users from using the
  // feature.
  $this
    ->drupalGet('admin/structure/views/nojs/add-handler/moderated_content/moderated_content/relationship');
  $this
    ->assertSession()
    ->pageTextContains('Deprecated: Content moderation state');
  $this
    ->assertSession()
    ->pageTextContains('Using a relationship to the Content Moderation State entity type has been deprecated');

  // Assert by default the deprecation warning does not appear in the status
  // report.
  $this
    ->drupalGet('admin/reports/status');
  $this
    ->assertSession()
    ->pageTextNotContains('Content Moderation State views relationship');

  // Install the views intended for testing the relationship and assert the
  // warning appears with the view name as a link.
  $this->container
    ->get('module_installer')
    ->install([
    'content_moderation_test_views',
  ]);
  $this
    ->drupalGet('admin/reports/status');
  $this
    ->assertSession()
    ->pageTextContains('Content Moderation State views relationship');
  $this
    ->assertSession()
    ->linkExists('test_content_moderation_base_table_test');
  $this
    ->assertSession()
    ->linkByHrefExists('admin/structure/views/view/test_content_moderation_base_table_test');

  // Uninstall views_ui and assert the warning appears with a plain text view
  // name.
  $this->container
    ->get('module_installer')
    ->uninstall([
    'views_ui',
  ]);
  $this
    ->drupalGet('admin/reports/status');
  $this
    ->assertSession()
    ->pageTextContains('Content Moderation State views relationship');
  $this
    ->assertSession()
    ->pageTextContains('test_content_moderation_base_table_test');
}