You are here

function HeartbeatAdminTools::testImport in Heartbeat 6.4

Tests if a heartbeat message templates are imported correct.

File

tests/heartbeat.admintools.test, line 37

Class

HeartbeatAdminTools
Class HeartbeatAdminTools

Code

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'));
}