private function MongoDBLogTestCase::doNode in MongoDB 8
Same name and namespace in other branches
- 6 mongodb_watchdog/mongodb_watchdog.test \MongoDBLogTestCase::doNode()
- 7 mongodb_watchdog/mongodb_watchdog.test \MongoDBLogTestCase::doNode()
Generate and verify node events.
Parameters
string $type Content type.:
1 call to MongoDBLogTestCase::doNode()
- MongoDBLogTestCase::verifyEvents in mongodb_watchdog/
mongodb_watchdog.test - Verify events.
File
- mongodb_watchdog/
mongodb_watchdog.test, line 407 - Test class for MongoDB_watchdog.
Class
- MongoDBLogTestCase
- Test the behaviour of watchdog() mongodb_watchdog, not dblog
Code
private function doNode($type) {
// Create user.
$perm = array(
'create ' . $type . ' content',
'edit own ' . $type . ' content',
'delete own ' . $type . ' content',
);
$user = $this
->drupalCreateUser($perm);
// Login user.
$this
->drupalLogin($user);
// Create node using form to generate add content event (which is not triggered by drupalCreateNode).
$edit = $this
->getContent($type);
$langcode = LANGUAGE_NONE;
$title = $edit["title[{$langcode}][0][value]"];
$this
->drupalPost('node/add/' . $type, $edit, t('Save'));
$this
->assertResponse(200);
// Retrieve node object.
$node = $this
->drupalGetNodeByTitle($title);
$this
->assertTrue($node != NULL, t('Node @title was loaded', array(
'@title' => $title,
)));
// Edit node.
$edit = $this
->getContentUpdate($type);
$this
->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
$this
->assertResponse(200);
// Delete node.
$this
->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
$this
->assertResponse(200);
// View node (to generate page not found event).
$this
->drupalGet('node/' . $node->nid);
$this
->assertResponse(404);
// View the dblog report (to generate access denied event).
$this
->drupalGet('admin/reports/dblog');
$this
->assertResponse(403);
// Login the admin user.
$this
->drupalLogin($this->big_user);
// View the dblog report.
$this
->drupalGet('admin/reports/dblog');
$this
->assertResponse(200);
// Verify events were recorded.
// Content added.
$this
->assertRaw(t('@type: added %title', array(
'@type' => $type,
'%title' => $title,
)), t('DBLog event was recorded: [content added]'));
// Content updated.
$this
->assertRaw(t('@type: updated %title', array(
'@type' => $type,
'%title' => $title,
)), t('DBLog event was recorded: [content updated]'));
// Content deleted.
$this
->assertRaw(t('@type: deleted %title', array(
'@type' => $type,
'%title' => $title,
)), t('DBLog event was recorded: [content deleted]'));
// View dblog access-denied report node.
$this
->drupalGet('admin/reports/access-denied');
$this
->assertResponse(200);
// Access denied.
$this
->assertText(t('admin/reports/dblog'), t('DBLog event was recorded: [access denied]'));
// View dblog page-not-found report node.
$this
->drupalGet('admin/reports/page-not-found');
$this
->assertResponse(200);
// Page not found.
$this
->assertText(t('node/@nid', array(
'@nid' => $node->nid,
)), t('DBLog event was recorded: [page not found]'));
}