function DisplayTest::testInvalidDisplayPlugins
Same name in other branches
- 9 core/modules/views/tests/src/Functional/Plugin/DisplayTest.php \Drupal\Tests\views\Functional\Plugin\DisplayTest::testInvalidDisplayPlugins()
- 8.9.x core/modules/views/tests/src/Functional/Plugin/DisplayTest.php \Drupal\Tests\views\Functional\Plugin\DisplayTest::testInvalidDisplayPlugins()
- 10 core/modules/views/tests/src/Functional/Plugin/DisplayTest.php \Drupal\Tests\views\Functional\Plugin\DisplayTest::testInvalidDisplayPlugins()
Tests invalid display plugins.
File
-
core/
modules/ views/ tests/ src/ Functional/ Plugin/ DisplayTest.php, line 323
Class
- DisplayTest
- Tests the basic display plugin.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testInvalidDisplayPlugins() : void {
$this->drupalGet('test_display_invalid');
$this->assertSession()
->statusCodeEquals(200);
// Change the page plugin id to an invalid one. Bypass the entity system
// so no menu rebuild was executed (so the path is still available).
$config = $this->config('views.view.test_display_invalid');
$config->set('display.page_1.display_plugin', 'invalid');
$config->save();
$this->drupalGet('test_display_invalid');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->pageTextContains('The "invalid" plugin does not exist.');
// Rebuild the router, and ensure that the path is not accessible anymore.
views_invalidate_cache();
\Drupal::service('router.builder')->rebuildIfNeeded();
$this->drupalGet('test_display_invalid');
$this->assertSession()
->statusCodeEquals(404);
// Change the display plugin ID back to the correct ID.
$config = $this->config('views.view.test_display_invalid');
$config->set('display.page_1.display_plugin', 'page');
$config->save();
// Place the block display.
$block = $this->drupalPlaceBlock('views_block:test_display_invalid-block_1', [
'label' => 'Invalid display',
]);
$this->drupalGet('<front>');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->elementsCount('xpath', "//div[@id = 'block-{$block->id()}']", 1);
// Change the block plugin ID to an invalid one.
$config = $this->config('views.view.test_display_invalid');
$config->set('display.block_1.display_plugin', 'invalid');
$config->save();
// Test the page is still displayed, the block not present, and has the
// plugin warning message.
$this->drupalGet('<front>');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->pageTextContains('The "invalid" plugin does not exist.');
$this->assertSession()
->elementNotExists('xpath', "//div[@id = 'block-{$block->id()}']");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.