You are here

function i18n_Blocks_Test::i18nCreateBox in Internationalization 6

Test creating custom block (i.e. box), moving it to a specific region and then deleting it.

1 call to i18n_Blocks_Test::i18nCreateBox()
i18n_Blocks_Test::testBlockTranslation in tests/i18n_blocks.test

File

tests/i18n_blocks.test, line 109

Class

i18n_Blocks_Test

Code

function i18nCreateBox($box = array(), $region = 'left', $check_display = TRUE) {

  // Add a new box by filling out the input form on the admin/build/block/add page.
  $box += array(
    'info' => $this
      ->randomName(8),
    'title' => $this
      ->randomName(8),
    '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.'), '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, 'Box found in database');

  // Display the block on left region
  $this
    ->i18nUpdateBlockRegion('block', $bid, $region);
  if ($check_display) {

    // Confirm that the box is being displayed.
    $this
      ->assertText(check_plain($box['title']), 'Box successfully being displayed on the page.');
  }
  $box['bid'] = $block['delta'] = $bid;
  $box['module'] = 'block';
  return (object) $box;
}