public function BlockContentCreationTest::testDefaultBlockContentCreation in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/block_content/src/Tests/BlockContentCreationTest.php \Drupal\block_content\Tests\BlockContentCreationTest::testDefaultBlockContentCreation()
Create a default custom block.
Creates a custom block from defaults and ensures that the 'basic block' type is being used.
File
- core/
modules/ block_content/ src/ Tests/ BlockContentCreationTest.php, line 171 - Contains \Drupal\block_content\Tests\BlockContentCreationTest.
Class
- BlockContentCreationTest
- Create a block and test saving it.
Namespace
Drupal\block_content\TestsCode
public function testDefaultBlockContentCreation() {
$edit = array();
$edit['info[0][value]'] = $this
->randomMachineName(8);
$edit['body[0][value]'] = $this
->randomMachineName(16);
// Don't pass the custom block type in the url so the default is forced.
$this
->drupalPostForm('block/add', $edit, t('Save'));
// Check that the block has been created and that it is a basic block.
$this
->assertRaw(format_string('@block %name has been created.', array(
'@block' => 'basic',
'%name' => $edit['info[0][value]'],
)), 'Basic block created.');
// Check that the block exists in the database.
$blocks = entity_load_multiple_by_properties('block_content', array(
'info' => $edit['info[0][value]'],
));
$block = reset($blocks);
$this
->assertTrue($block, 'Default Custom Block found in database.');
}