function BlockUiTest::testMachineNameSuggestion
Same name in other branches
- 9 core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testMachineNameSuggestion()
- 8.9.x core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testMachineNameSuggestion()
- 11.x 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 275
Class
- BlockUiTest
- Tests that the block configuration UI exists and stores data correctly.
Namespace
Drupal\Tests\block\FunctionalCode
public function testMachineNameSuggestion() : void {
// Check the form uses the raw machine name suggestion when no instance
// already exists.
$url = 'admin/structure/block/add/test_block_instantiation/stark';
$this->drupalGet($url);
$this->assertSession()
->fieldValueEquals('id', 'stark_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 auto-incrementing correctly.
$this->drupalGet($url);
$this->assertSession()
->fieldValueEquals('id', 'stark_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', 'stark_displaymessage_3');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.