You are here

heartbeat.admintools.test in Heartbeat 6.4

File

tests/heartbeat.admintools.test
View source
<?php

/**
 * @file
 *   Tests the administration tasks within heartbeat.
 */
require_once dirname(__FILE__) . '/heartbeatwebtestcase.inc';

/**
 * Class HeartbeatAdminTools
 *
 */
class HeartbeatAdminTools extends HeartbeatWebTestCase {

  /**
   * Implementation of setUp().
   */
  function setUp() {
    parent::setUp('heartbeat', 'heartbeattest');
  }

  /**
   * Implementation of getInfo().
   */
  function getInfo() {
    return array(
      'name' => t('Heartbeat administration tools'),
      'description' => t('Test heartbeat administration tools.'),
      'group' => t('Heartbeat'),
    );
  }

  /**
   * Tests if a heartbeat message templates are imported correct.
   */
  function testImport() {
    $this
      ->drupalLogin($this
      ->drupalCreateUser($this->testRoles));

    // Make sure message templates are imported. This should not be needed.
    $this
      ->drupalGet('admin/build/heartbeat');
    $this
      ->assertText('heartbeattest_add_node', t('The test message template we are using is imported and available.'), t('Heartbeat'));

    // Test the configuration form for private heartbeat.
    $this
      ->drupalGet('admin/build/heartbeat/stream/privateheartbeat');
    $type = heartbeat_stream_load('privateheartbeat');
    $this
      ->assertEqual(15, $type['settings']['page_items_max'], t('Items per page default value is correct'), t('Heartbeat'));
    $this
      ->assertEqual(1, $type['settings']['page_pager_ajax'], t('Ajax default setting for pages is correct'), t('Heartbeat'));

    // Test changes to this settings.
    $edit = array(
      'page_items_max' => 2,
      'page_show_pager' => FALSE,
      'page_pager_ajax' => FALSE,
    );
    $this
      ->drupalPost('admin/build/heartbeat/stream/privateheartbeat', $edit, t('Submit'));
    $type = heartbeat_stream_load('privateheartbeat');
    $this
      ->assertEqual($edit['page_items_max'], $type['settings']['page_items_max'], t('Items per page is set correctly'), t('Heartbeat'));
    $this
      ->assertEqual($edit['page_show_pager'], $type['settings']['page_show_pager'], t('Show pager is set correctly'), t('Heartbeat'));
    $this
      ->assertEqual($edit['page_pager_ajax'], $type['settings']['page_pager_ajax'], t('Ajax setting is set correctly'), t('Heartbeat'));
    $this
      ->drupalGet('admin/build/heartbeat/stream/privateheartbeat');

    // Test the cloning of a stream.
    $this
      ->drupalPost('admin/build/heartbeat/stream/privateheartbeat/clone', array(
      'stream_name' => 'My Personal Activity',
    ), t('Clone stream'));
    $this
      ->drupalGet('admin/build/heartbeat/streams');
    $this
      ->assertText('My Personal Activity', t('The stream is cloned.'), t('Heartbeat'));

    // Test the configuration of original and cloned stream.
    $edit2 = array(
      'page_items_max' => 20,
      'page_show_pager' => TRUE,
      'page_pager_ajax' => TRUE,
    );
    $this
      ->drupalPost('admin/build/heartbeat/stream/mypersonalactivity', $edit2, t('Submit'));
    $type2 = heartbeat_stream_load('mypersonalactivity');
    $this
      ->assertEqual($edit2['page_items_max'], $type2['settings']['page_items_max'], t('Items per page is set correctly'), t('Heartbeat'));
    $this
      ->assertEqual($edit2['page_show_pager'], $type2['settings']['page_show_pager'], t('Show pager is set correctly'), t('Heartbeat'));
    $this
      ->assertEqual($edit2['page_pager_ajax'], $type2['settings']['page_pager_ajax'], t('Ajax setting is set correctly'), t('Heartbeat'));

    // Recheck originals.
    $this
      ->drupalGet('admin/build/heartbeat/stream/privateheartbeat');
    $type = heartbeat_stream_load('privateheartbeat');
    $this
      ->assertEqual($edit['page_items_max'], $type['settings']['page_items_max'], t('Items per page is set correctly'), t('Heartbeat'));
    $this
      ->assertEqual($edit['page_show_pager'], $type['settings']['page_show_pager'], t('Show pager is set correctly'), t('Heartbeat'));
  }

}

Classes

Namesort descending Description
HeartbeatAdminTools Class HeartbeatAdminTools