You are here

function GoogleCalendarBlockTestCase::moveBlockToRegion in Google Calendar Block 7.2

Same name and namespace in other branches
  1. 7 tests/google_calendar_block.test \GoogleCalendarBlockTestCase::moveBlockToRegion()
1 call to GoogleCalendarBlockTestCase::moveBlockToRegion()
GoogleCalendarBlockTestCase::testGoogleCalendarBlock in tests/google_calendar_block.test
Test creating custom Google Calendar block, moving it to a specific region and then deleting it.

File

tests/google_calendar_block.test, line 89
Tests for Google Calendar Block module.

Class

GoogleCalendarBlockTestCase
@file Tests for Google Calendar Block module.

Code

function moveBlockToRegion($block, $region) {

  // Set the created block to a specific region.
  $edit = array();
  $edit['blocks[' . $block['module'] . '_' . $block['delta'] . '][region]'] = $region;
  $this
    ->drupalPost('admin/structure/block', $edit, t('Save blocks'));

  // Confirm that the block was moved to the proper region.
  $this
    ->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', array(
    '%region_name' => $region,
  )));

  // Confirm that the block is being displayed.
  $this
    ->drupalGet('node');
  $this
    ->assertText(t($block['title']), 'Block successfully being displayed on the page.');

  // Confirm that the custom Google Calendar block was found at the proper region.
  $xpath = $this
    ->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array(
    ':region-class' => 'region region-' . str_replace('_', '-', $region),
    ':block-id' => 'block-' . drupal_clean_css_identifier($block['module']) . '-' . $block['delta'],
  ));
  $this
    ->assertFieldByXPath($xpath, NULL, format_string('Custom Google Calendar block found in %region_name region.', array(
    '%region_name' => $region,
  )));
}