View source
<?php
require_once dirname(__FILE__) . '/heartbeatwebtestcase.inc';
class HeartbeatFunctionalTest extends HeartbeatWebTestCase {
function setUp() {
parent::setUp('heartbeat', 'heartbeattest');
}
function getInfo() {
return array(
'name' => t('Heartbeat Functional'),
'description' => t('Tests for heartbeat functionality.'),
'group' => t('Heartbeat'),
);
}
function testOlderActivity() {
$this
->drupalLogin($this
->drupalCreateUser($this->testRoles));
$edit = array(
'page_items_max' => 2,
'page_pager_ajax' => FALSE,
);
$this
->configureStream('publicheartbeat', $edit);
$time = $_SERVER['REQUEST_TIME'];
$this
->drupalCreateNode(array(
'title' => 'MyFirstTitle',
));
$_SERVER['REQUEST_TIME'] += 1;
$this
->drupalCreateNode(array(
'title' => 'MySecondTitle',
));
$_SERVER['REQUEST_TIME'] += 1;
$this
->drupalCreateNode(array(
'title' => 'MyThirdTitle',
));
$_SERVER['REQUEST_TIME'] += 1;
$this
->drupalCreateNode(array(
'title' => 'MyFourthTitle',
));
$_SERVER['REQUEST_TIME'] += 1;
$this
->drupalCreateNode(array(
'title' => 'MyFifthTitle',
));
$_SERVER['REQUEST_TIME'] = $time;
$this
->drupalGet('heartbeat/publicheartbeat');
$this
->assertText('MyFifthTitle', t('Fifth title is displayed in the public stream.'), t('Heartbeat'));
$this
->assertText('MyFourthTitle', t('Fourth title is displayed in the public stream.'), t('Heartbeat'));
$this
->assertText('MyThirdTitle', t('Third title is displayed in the public stream.'), t('Heartbeat'));
$edit = array(
'type' => 'single',
);
$this
->drupalPost('admin/build/heartbeat/edit/1', $edit, t('Save'));
$this
->drupalGet('heartbeat/publicheartbeat');
$this
->assertText('MyFifthTitle', t('Fifth title is displayed in the public stream.'), t('Heartbeat'));
$this
->assertNoText('MyThirdTitle', t('Third title is not displayed in the public stream.'), t('Heartbeat'));
$this
->clickLink(t('Older messages'));
$this
->assertText('MyThirdTitle', t('Third title is now displayed in the public stream.'), t('Heartbeat'));
$this
->clickLink(t('Older messages'));
$this
->assertText('MyFirstTitle', t('First title is now displayed in the public stream.'), t('Heartbeat'));
$this
->clickLink(t('Go to previous messages'));
$this
->assertText('MyFourthTitle', t('Fourth title is now displayed in the public stream.'), t('Heartbeat'));
}
function testPollActivity() {
$this
->drupalLogin($this
->drupalCreateUser($this->testRoles));
$page_node = $this
->drupalCreateNode(array(
'type' => 'page',
'title' => 'MyPageTitle',
));
$options = array(
'query' => 'stream=publicheartbeat&latestUaid=0&uaids=',
);
$this
->drupalGet('heartbeat/js/poll', $options);
$this
->assertText('MyPageTitle', t('The page title is displayed in the public heartbeat stream ajax response.'), t('Heartbeat'));
}
}