heartbeat.api.test in Heartbeat 7
Same filename and directory in other branches
Heartbeat API tests.
File
tests/heartbeat.api.testView source
<?php
/**
* @file
* Heartbeat API tests.
*/
/**
* Test basic API.
*/
class HeartbeatAPI extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Heartbeat API',
'description' => 'Tests for heartbeat API.',
'group' => 'Heartbeat API',
);
}
function setUp() {
parent::setUp('heartbeat', 'heartbeat_defaults', 'heartbeat_example');
}
/**
* Creates a simple node, used to populate heartbeat activity table.
*/
private function createSimpleNode() {
// Create a node.
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title"] = $this
->randomName(8);
$edit["body[{$langcode}][0][value]"] = $this
->randomName(16);
$this
->drupalPost('node/add/page', $edit, t('Save'));
// Check that the Basic page has been created.
$this
->assertRaw(t('!post %title has been created.', array(
'!post' => 'Basic page',
'%title' => $edit["title"],
)), t('Basic page created.'));
return $edit["title"];
}
/**
* Tests logging through API function calls.
*/
function testLogging() {
$web_user = $this
->drupalCreateUser(array(
'create page content',
'edit own page content',
'view heartbeat messages',
'view Site activity stream',
));
$this
->drupalLogin($web_user);
// Create a node, logging should follow.
$title = $this
->createSimpleNode();
// Go to the public siteactivity with this user and check if it's there.
$page = $this
->drupalGet('heartbeat/siteactivity');
$this
->assertRaw($title, t('Node activity is shown.'));
}
}
Classes
Name![]() |
Description |
---|---|
HeartbeatAPI | Test basic API. |