You are here

public function ProtectedNodePrivateFile::createProtectedNode in Protected Node 1.0.x

Same name and namespace in other branches
  1. 7 tests/protected_node.private_file.test \ProtectedNodePrivateFile::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.

5 calls to ProtectedNodePrivateFile::createProtectedNode()
ProtectedNodePrivateFile::testAllowedView in tests/protected_node.private_file.test
Test function.
ProtectedNodePrivateFile::testAllowedViewWrongPassword in tests/protected_node.private_file.test
Test function.
ProtectedNodePrivateFile::testAuthenticatedMultipleNodesAllowedView in tests/protected_node.private_file.test
Test function.
ProtectedNodePrivateFile::testAuthenticatedNonAllowedView in tests/protected_node.private_file.test
Test function.
ProtectedNodePrivateFile::testBypassView in tests/protected_node.private_file.test
Test function.

File

tests/protected_node.private_file.test, line 275
Test protected node behavior with private files.

Class

ProtectedNodePrivateFile
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),
    'private_file[und][0][fid]' => $this->text_file->fid,
    '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);
}