You are here

protected function MediaWYSIWYGTestHelper::createNode in D7 Media 7.4

Same name and namespace in other branches
  1. 7.2 modules/media_wysiwyg/media_wysiwyg.test \MediaWYSIWYGTestHelper::createNode()
  2. 7.3 modules/media_wysiwyg/media_wysiwyg.test \MediaWYSIWYGTestHelper::createNode()

Utility function to create a test node.

Parameters

int $fid: Create the node with media markup in the body field

array $attributes: Extra attributes to insert to the file.

array $fields: Extra field values to insert.

Return value

int Returns the node id

7 calls to MediaWYSIWYGTestHelper::createNode()
MediaWYSIWYGFileUsageTest::testFileUsageForcedDelete in modules/media_wysiwyg/tests/media_wysiwyg.file_usage.test
Tests if node still remains updatable if file was deleted.
MediaWYSIWYGFileUsageTest::testFileUsageIncrementing in modules/media_wysiwyg/tests/media_wysiwyg.file_usage.test
Tests the tracking of file usages for files submitted via the WYSIWYG editor.
MediaWYSIWYGFileUsageTest::testFileUsageIncrementingDelete in modules/media_wysiwyg/tests/media_wysiwyg.file_usage.test
Tests the behavior of node and file deletion.
MediaWYSIWYGParagraphFixFilterTest::testMediaFilterParagraphFixDefault in modules/media_wysiwyg/tests/media_wysiwyg.paragraph_fix_filter.test
Test image media overrides.
MediaWYSIWYGParagraphFixFilterTest::testMediaFilterParagraphFixMultipleImages in modules/media_wysiwyg/tests/media_wysiwyg.paragraph_fix_filter.test
Test image media overrides.

... See full list

File

modules/media_wysiwyg/media_wysiwyg.test, line 82
Tests for media.module.

Class

MediaWYSIWYGTestHelper
Defines base class for media test cases.

Code

protected function createNode($fid = FALSE, array $attributes = array(), array $fields = array()) {
  $markup = '';
  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;
}