You are here

private function MediaFileUsageTest::createNode in D7 Media 7

Utility function to create a test node.

Parameters

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

Return value

int Returns the node id

2 calls to MediaFileUsageTest::createNode()
MediaFileUsageTest::testFileUsageIncrementing in test/media.file.usage.test
Tests the tracking of file usages for files submitted via the WYSIWYG editor.
MediaFileUsageTest::testFileUsageIncrementingDelete in test/media.file.usage.test
Tests the behavior of node and file deletion.

File

test/media.file.usage.test, line 76
Tests for the file usage in entity fields with the Media filter markup.

Class

MediaFileUsageTest
@file Tests for the file usage in entity fields with the Media filter markup.

Code

private function createNode($fid = FALSE) {
  $markup = '';
  if (!empty($fid)) {
    $markup = $this
      ->generateFileMarkup($fid);
  }

  // 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;
}