You are here

public function ProtectedNodeFieldCollection::createProtectedNode in Protected Node 7

Same name and namespace in other branches
  1. 1.0.x tests/protected_node.field_collection.test \ProtectedNodeFieldCollection::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 ProtectedNodeFieldCollection::createProtectedNode()
ProtectedNodeFieldCollection::createProtectedNodeWithFieldCollection in tests/protected_node.field_collection.test
Helper for creating a new protected node with a field collection item.

File

tests/protected_node.field_collection.test, line 216
Test protected node behavior with field collection private files.

Class

ProtectedNodeFieldCollection
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);
  $node_data = array(
    'title' => $node_title,
    'body[und][0][value]' => $this
      ->randomName(32),
    'files[' . $this->field_collection_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('node/add/page', $node_data, t('Save'));
  return $this
    ->drupalGetNodeByTitle($node_title);
}