You are here

protected function MediaCkeditorTestHelper::createNode in Media CKEditor 7.2

Utility function to create a test node.

Parameters

array $fields: Extra field values to insert.

Return value

int Returns the node id

1 call to MediaCkeditorTestHelper::createNode()
MediaCkeditorViewModeTestHelper::testCreateNodeAndDelete in tests/media_ckeditor.test
Tests the behavior of node and file deletion.

File

tests/media_ckeditor.test, line 84
Tests for media_ckeditor.module.

Class

MediaCkeditorTestHelper
Defines base class for media test cases.

Code

protected function createNode(array $fields = array()) {
  $markup = 'test';

  // If (! empty($fid)) {
  // $markup = $this->generateJsonTokenMarkup($fid, 1, $attributes, $fields);
  // }
  // Create an article node with file markup in the body field.
  $edit = array(
    'title' => $this
      ->randomName(8),
    'body[und][0][value]' => $markup,
  );

  // Save the article node. First argument is the URL, then the value array
  // and the third is the label the button that should be "clicked".
  $this
    ->drupalPost('node/add/article', $edit, t('Save'));

  // Get the article node that was saved by the unique title.
  $node = $this
    ->drupalGetNodeByTitle($edit['title']);
  return $node->nid;
}