public function BlockTest::testBlockExists in Style Switcher 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/BlockTest.php \Drupal\Tests\styleswitcher\Functional\BlockTest::testBlockExists()
Tests that the Style Switcher block exists and functions as a normal block.
File
- tests/
src/ Functional/ BlockTest.php, line 29
Class
- BlockTest
- Tests the Style Switcher block.
Namespace
Drupal\Tests\styleswitcher\FunctionalCode
public function testBlockExists() {
$assert = $this
->assertSession();
$user = $this
->drupalCreateUser([
'administer blocks',
]);
$this
->drupalLogin($user);
// Test if the block exists.
$this
->drupalGet('admin/structure/block/add/styleswitcher_styleswitcher');
$assert
->fieldValueEquals('id', 'styleswitcher');
// Test if the block is configurable.
$label = $this
->randomString();
$edit = [
'settings[label]' => $label,
'region' => 'sidebar_first',
];
$this
->submitForm($edit, 'Save block');
$assert
->pageTextContains('The block configuration has been saved.');
// Test the block is added to the block layout.
$assert
->elementTextContains('css', '#blocks', $label);
}