Commit 54ed0941 authored by alexpott's avatar alexpott

Issue #3099364 by wells, Dinesh18, Sam152, Berdir: Content Moderation...

Issue #3099364 by wells, Dinesh18, Sam152, Berdir: Content Moderation requirements check relies on Views UI module

(cherry picked from commit 4c381596)
parent 1bce7388
......@@ -15,13 +15,20 @@ function content_moderation_requirements($phase) {
$requirements = [];
if ($phase === 'runtime') {
$moduleHandler = \Drupal::moduleHandler();
$config = \Drupal::configFactory();
$legacy_views = [];
foreach ($config->listAll('views.view.') as $view_id) {
$view = $config->get($view_id);
foreach ($view->get('display') as $display) {
if (!empty($display['display_options']['relationships']['moderation_state'])) {
$legacy_views[] = Link::createFromRoute($view->get('label'), 'entity.view.edit_form', ['view' => $view->get('id')])->toString();
if ($moduleHandler->moduleExists('views_ui')) {
$view_name = Link::createFromRoute($view->get('label'), 'entity.view.edit_form', ['view' => $view->get('id')])->toString();
}
else {
$view_name = $view->get('label');
}
$legacy_views[] = $view_name;
}
}
}
......
......@@ -59,12 +59,19 @@ public function testReportDeprecatedModerationStateRelationships() {
$this->assertSession()->pageTextNotContains('Content Moderation State views relationship');
// Install the views intended for testing the relationship and assert the
// warning does appear.
// 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');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment