public function SettingsTrayTest::testPossibleAnnotations in Drupal 8
Same name and namespace in other branches
- 9 core/modules/settings_tray/tests/src/Functional/SettingsTrayTest.php \Drupal\Tests\settings_tray\Functional\SettingsTrayTest::testPossibleAnnotations()
Tests the 3 possible forms[settings_tray] annotations: class, FALSE, none.
There is also functional JS test coverage to ensure that the two blocks that support Settings Tray (the "class" and "none" cases) do work correctly.
See also
SettingsTrayBlockFormTest::testBlocks()
File
- core/
modules/ settings_tray/ tests/ src/ Functional/ SettingsTrayTest.php, line 50
Class
- SettingsTrayTest
- Tests opening and saving block forms in the off-canvas dialog.
Namespace
Drupal\Tests\settings_tray\FunctionalCode
public function testPossibleAnnotations() {
$test_block_plugin_ids = [
// Block that explicitly provides an "settings_tray" form class.
'settings_tray_test_class',
// Block that explicitly provides no "settings_tray" form, thus opting out.
'settings_tray_test_false',
// Block that does nothing explicit for Settings Tray.
'settings_tray_test_none',
];
$placed_blocks = [];
foreach ($test_block_plugin_ids as $plugin_id) {
$placed_blocks[$plugin_id] = $this
->placeBlock($plugin_id);
}
$this
->drupalGet('');
$web_assert = $this
->assertSession();
foreach ($placed_blocks as $plugin_id => $placed_block) {
$block_selector = $this
->getBlockSelector($placed_block);
// All blocks are rendered.
$web_assert
->elementExists('css', $block_selector);
// All blocks except 'settings_tray_test_false' are editable. For more
// detailed test coverage, which requires JS execution, see
// \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testBlocks().
if ($plugin_id === 'settings_tray_test_false') {
$web_assert
->elementNotExists('css', "{$block_selector}[data-drupal-settingstray=\"editable\"]");
}
else {
$web_assert
->elementExists('css', "{$block_selector}[data-drupal-settingstray=\"editable\"]");
}
}
}