function BlockTestCase::testBox in SimpleTest 6.2
Test creating custom block (i.e. box), moving it to a specific region and then deleting it.
File
- tests/
block.test, line 35 - Backport of Drupal 7 block.test with modifications, see BACKPORT.txt.
Class
- BlockTestCase
- @file Backport of Drupal 7 block.test with modifications, see BACKPORT.txt.
Code
function testBox() {
// Add a new box by filling out the input form on the admin/build/block/add page.
$box = array();
$box['info'] = $this
->randomName(8);
$box['title'] = $this
->randomName(8);
$box['body'] = $this
->randomName(32);
$this
->drupalPost('admin/build/block/add', $box, t('Save block'));
// Confirm that the box has been created, and then query the created bid.
$this
->assertText(t('The block has been created.'), t('Box successfully created.'));
$bid = db_result(db_query("SELECT bid FROM {boxes} WHERE info = '%s'", array(
$box['info'],
)));
// Check to see if the box was created by checking that it's in the database..
$this
->assertNotNull($bid, t('Box found in database'));
// Set the created box to a specific region.
// TODO: Implement full region checking.
$edit = array();
$edit['block_' . $bid . '[region]'] = 'left';
$this
->drupalPost('admin/build/block', $edit, t('Save blocks'));
// Confirm that the box was moved to the proper region.
$this
->assertText(t('The block settings have been updated.'), t('Box successfully moved to left region.'));
// Confirm that the box is being displayed.
$this
->assertText(t($box['title']), t('Box successfully being displayed on the page.'));
// Delete the created box & verify that it's been deleted and no longer appearing on the page.
$this
->drupalPost('admin/build/block/delete/' . $bid, array(), t('Delete'));
$this
->assertRaw(t('The block %title has been removed.', array(
'%title' => $box['info'],
)), t('Box successfully deleted.'));
$this
->assertNoText(t($box['title']), t('Box no longer appears on page.'));
}