function i18nBlocksTestCase::i18nCreateBlock in Internationalization 7
Test creating custom block (i.e. box), moving it to a specific region and then deleting it.
1 call to i18nBlocksTestCase::i18nCreateBlock()
- i18nBlocksTestCase::testBlockTranslation in i18n_block/
i18n_block.test
File
- i18n_block/
i18n_block.test, line 134 - Test case for multilingual blocks
Class
- i18nBlocksTestCase
- @file Test case for multilingual blocks
Code
function i18nCreateBlock($block = array(), $region = 'sidebar_first', $check_display = TRUE) {
$this
->drupalLogin($this->admin_user);
// Add a new custom block by filling out the input form on the admin/structure/block/add page.
$block += array(
'info' => $this
->randomName(8),
'title' => $this
->randomName(8),
'i18n_mode' => I18N_MODE_LOCALIZE,
'body' => $this
->randomName(16),
);
$custom_block = array(
'info' => $block['info'],
'title' => $block['title'],
'i18n_mode' => $block['i18n_mode'],
'body[value]' => $block['body'],
);
$this
->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
// Confirm that the custom block has been created, and then query the created bid.
$this
->assertText(t('The block has been created.'), t('Custom block successfully created.'));
$bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(
':info' => $block['info'],
))
->fetchField();
// Check to see if the custom block was created by checking that it's in the database.
$this
->assertNotNull($bid, t('Custom block found in database'));
// Check that block_block_view() returns the correct title and content.
$data = block_block_view($bid);
$format = db_query("SELECT format FROM {block_custom} WHERE bid = :bid", array(
':bid' => $bid,
))
->fetchField();
$this
->assertTrue(array_key_exists('subject', $data) && empty($data['subject']), t('block_block_view() provides an empty block subject, since custom blocks do not have default titles.'));
$this
->assertEqual(check_markup($block['body'], $format), $data['content'], t('block_block_view() provides correct block content.'));
// Check if the block can be moved to all available regions.
$block['module'] = 'block';
$block['delta'] = $bid;
$block['format'] = $format;
$this
->moveBlockToRegion($block, $region);
return $block;
}