You are here

block_refresh.test in Block Refresh 7.2

File

block_refresh.test
View source
<?php

/**
 * Tests functionality of the block refresh module.
 */
class BlockRefreshSettingsTestCase extends DrupalWebTestCase {
  protected $privileged_user;
  public static function getInfo() {

    // Note: getInfo() strings are not translated with t().
    return array(
      'name' => 'Block Refresh Block config settings form',
      'description' => 'Ensure block refresh settings appear on the block config page.',
      'group' => 'Block Refresh',
    );
  }
  public function setUp() {

    // Enable any modules required for the test. This should be an array of
    // module names.
    parent::setUp(array(
      'block_refresh',
      'block_refresh_demo',
    ));

    // Create and log in our privileged user.
    $this->privileged_user = $this
      ->drupalCreateUser(array(
      'administer blocks',
    ));
    $this
      ->drupalLogin($this->privileged_user);

    // Define the existing regions
    $this->regions = array();
    $this->regions[] = 'header';
    $this->regions[] = 'sidebar_first';
    $this->regions[] = 'content';
    $this->regions[] = 'sidebar_second';
    $this->regions[] = 'footer';
  }

  //Check if the block refresh elements appear on the configure form.
  public function testBlockRefreshConfigureForm() {
    $configure_path = 'admin/structure/block/manage/block_refresh_demo/block_refresh_demo/configure';
    $this
      ->drupalGet($configure_path);
    $this
      ->assertText('Block refresh settings');

    //Auto refresh
    $this
      ->assertText('Enable block to be refreshed automatically');
    $this
      ->assertFieldById('edit-block-refresh-auto');

    //Timed refresh
    $this
      ->assertText('Block refresh timer');
    $this
      ->assertFieldById('edit-block-refresh-timer');

    // Manual refresh.
    $this
      ->assertText('Enable block to be refreshed manually');
    $this
      ->assertFieldById('edit-block-refresh-manual');

    // Initial refresh.
    $this
      ->assertText('Enable block to be refreshed on page load');
    $this
      ->assertFieldById('edit-block-refresh-init');

    // Send path arguments option.
    $this
      ->assertText('Send page path arguments to block');
    $this
      ->assertFieldById('edit-block-refresh-arguments');

    // Panels support
    $this
      ->assertText('Enable block to be used in Panels');
    $this
      ->assertFieldById('edit-block-refresh-panels');

    // Bypass drupal page cache
    $this
      ->assertText('Bypass Drupal page cache');
    $this
      ->assertFieldById('edit-block-refresh-bypass-page-cache');

    // External cache max age field.
    $this
      ->assertText('External cache max age');
    $this
      ->assertFieldById('edit-block-refresh-bypass-external-cache');

    // Change some form values, save, then check if the values are saved to
    // the block_refresh_settings variable.
    // We should also reload the form and check if the saved values display OK.
    $edit_auto = array(
      'block_refresh_auto' => '0',
    );
    $this
      ->drupalPost($configure_path, $edit_auto, t('Save block'));
    $settings = variable_get('block_refresh_settings');
  }

}

Classes

Namesort descending Description
BlockRefreshSettingsTestCase Tests functionality of the block refresh module.