public function BlockUiTest::testMachineNameSuggestion in Drupal 9
Same name and namespace in other branches
- 8 core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testMachineNameSuggestion()
Tests that the BlockForm populates machine name correctly.
File
- core/
modules/ block/ tests/ src/ Functional/ BlockUiTest.php, line 274
Class
- BlockUiTest
- Tests that the block configuration UI exists and stores data correctly.
Namespace
Drupal\Tests\block\FunctionalCode
public function testMachineNameSuggestion() {
// Check the form uses the raw machine name suggestion when no instance
// already exists.
$url = 'admin/structure/block/add/test_block_instantiation/classy';
$this
->drupalGet($url);
$this
->assertSession()
->fieldValueEquals('id', 'displaymessage');
$edit = [
'region' => 'content',
];
$this
->drupalGet($url);
$this
->submitForm($edit, 'Save block');
$this
->assertSession()
->pageTextContains('The block configuration has been saved.');
// Now, check to make sure the form starts by autoincrementing correctly.
$this
->drupalGet($url);
$this
->assertSession()
->fieldValueEquals('id', 'displaymessage_2');
$this
->drupalGet($url);
$this
->submitForm($edit, 'Save block');
$this
->assertSession()
->pageTextContains('The block configuration has been saved.');
// And verify that it continues working beyond just the first two.
$this
->drupalGet($url);
$this
->assertSession()
->fieldValueEquals('id', 'displaymessage_3');
}