You are here

public function ProtectedNodeParagraphs::createProtectedNode in Protected Node 7

Same name and namespace in other branches
  1. 1.0.x tests/protected_node.paragraphs.test \ProtectedNodeParagraphs::createProtectedNode()

Helper method to create a protected node.

Please make sure the user has the permission to create the node before calling the method.

Parameters

string $password: A password.

Return value

object A node object.

1 call to ProtectedNodeParagraphs::createProtectedNode()
ProtectedNodeParagraphs::createProtectedNodeWithParagraphs in tests/protected_node.paragraphs.test
Helper for creating a new protected node with a nested paragraphs item.

File

tests/protected_node.paragraphs.test, line 200
Test protected node behavior with paragraphs private files.

Class

ProtectedNodeParagraphs
Configure protected_node to use per node password and use private file field.

Code

public function createProtectedNode($password) {

  // Add a new page node that is protected.
  $node_title = $this
    ->randomName(8);
  $this
    ->drupalGet('node/add/page');

  // Add a new paragraph before saving node.
  $this
    ->drupalPost(NULL, array(), t('Add new Paragraph'));

  // Add a new nested paragraph before saving node.
  $this
    ->drupalPost(NULL, array(), t('Add new Paragraph'));
  $node_data = array(
    'title' => $node_title,
    'body[und][0][value]' => $this
      ->randomName(32),
    'files[' . $this->paragraphs_field_name . '_und_0_' . $this->paragraphs_field_name . '_und_0_' . $this->private_file_field_name . '_und_0]' => drupal_realpath(current($this
      ->drupalGetTestFiles('text'))->uri),
    'protected_node_is_protected' => TRUE,
    'protected_node_passwd[pass1]' => $password,
    'protected_node_passwd[pass2]' => $password,
  );
  $this
    ->drupalPost(NULL, $node_data, t('Save'));
  return $this
    ->drupalGetNodeByTitle($node_title);
}