You are here

public function ProtectedNodePageDisplay::createProtectedNode in Protected Node 7

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

Helper method to create a protected node.

Parameters

bool $show_title_option_available: TRUE if the show title option can be set in the UI, FALSE if it is hidden.

bool $show_title: Whether to show the node title or not. Has no effect if $show_title_option_available is FALSE.

Return value

object A node object.

5 calls to ProtectedNodePageDisplay::createProtectedNode()
ProtectedNodePageDisplay::testContentTypeDescriptionOnly in tests/protected_node.page_text.test
Test function.
ProtectedNodePageDisplay::testContentTypeWithGlobalDescriptionSet in tests/protected_node.page_text.test
Test function.
ProtectedNodePageDisplay::testDefaultHideTitle in tests/protected_node.page_text.test
Test function.
ProtectedNodePageDisplay::testDefaultShowTitle in tests/protected_node.page_text.test
Test function.
ProtectedNodePageDisplay::testGlobalDescriptionOnly in tests/protected_node.page_text.test
Test function.

File

tests/protected_node.page_text.test, line 176
Test protected node password page display options.

Class

ProtectedNodePageDisplay
Configure protected_node to use per node password.

Code

public function createProtectedNode($show_title_option_available, $show_title = FALSE) {

  // Log in as Admin.
  $this
    ->drupalLogin($this->adminUser);

  // Generate random password.
  $password = $this
    ->randomName(10);
  $node_data = array(
    'title' => $this
      ->randomName(8),
    'body[und][0][value]' => $this
      ->randomName(32),
    'protected_node_is_protected' => TRUE,
    'protected_node_passwd[pass1]' => $password,
    'protected_node_passwd[pass2]' => $password,
  );
  if ($show_title_option_available) {
    $node_data += array(
      'protected_node_show_title' => $show_title,
    );
  }
  $this
    ->drupalPost('node/add/page', $node_data, t('Save'));

  // Once the node created logout the user.
  $this
    ->drupalLogout();
  return $this
    ->drupalGetNodeByTitle($node_data['title']);
}