public function BlockTest::testCustomBlockFormat in MongoDB 7
Test creating custom block using Full HTML.
File
- mongodb_block_ui/
src/ Tests/ BlockTest.php, line 129
Class
- BlockTest
- Class BlockTest.
Namespace
Drupal\mongodb_block_ui\TestsCode
public function testCustomBlockFormat() {
// Add a new custom block by filling out the input form on the
// admin/structure/block/add page.
$custom_block = array();
$custom_block['info'] = $this
->randomName(8);
$custom_block['title'] = $this
->randomName(8);
$custom_block['body[value]'] = '<h1>Full HTML</h1>';
$full_html_format_id = db_query_range('SELECT format FROM {filter_format} WHERE name = :name', 0, 1, array(
':name' => 'Full HTML',
))
->fetchField();
$custom_block['body[format]'] = $full_html_format_id;
$this
->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
// Set the created custom block to a specific region.
$bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(
':info' => $custom_block['info'],
))
->fetchField();
$edit = array();
$edit['block_' . $bid . '[region]'] = $this->regions[1]['name'];
$this
->drupalPost('admin/structure/block', $edit, t('Save blocks'));
// Confirm that the custom block is being displayed using configured text
// format.
$this
->drupalGet('node');
$this
->assertRaw('<h1>Full HTML</h1>', t('Custom block successfully being displayed using Full HTML.'));
// Confirm that a user without access to Full HTML can not see the body
// field, but can still submit the form without errors.
$block_admin = $this
->drupalCreateUser(array(
'administer blocks',
));
$this
->drupalLogin($block_admin);
$this
->drupalGet('admin/structure/block/manage/block/' . $bid . '/configure');
$this
->assertNoText(t('Block body'));
$this
->drupalPost('admin/structure/block/manage/block/' . $bid . '/configure', array(), t('Save block'));
$this
->assertNoText(t('Ensure that each block description is unique.'));
// Confirm that the custom block is still being displayed using configured
// text format.
$this
->drupalGet('node');
$this
->assertRaw('<h1>Full HTML</h1>', t('Custom block successfully being displayed using Full HTML.'));
}