public function ProtectedNodePerNodePassword::testAllowedView in Protected Node 7
Same name and namespace in other branches
- 1.0.x tests/protected_node.per_node.test \ProtectedNodePerNodePassword::testAllowedView()
Test function.
Test that a node protected with per node protection can be seen with the right password.
File
- tests/protected_node.per_node.test, line 66 
- Test protected node per node functionality.
Class
- ProtectedNodePerNodePassword
- Configure protected_node to use per node password.
Code
public function testAllowedView() {
  // Log in as Admin.
  $this
    ->drupalLogin($this->adminUser);
  // Generate random password.
  $password = $this
    ->randomName(10);
  // Create a new page node.
  $node = $this
    ->createProtectedNode($password);
  // Once the node created logout the user.
  $this
    ->drupalLogout();
  // An authenticated user sees the node.
  $this
    ->drupalLogin($this->normalAccessAllowedUser);
  $form = array(
    'password' => $password,
  );
  $this
    ->drupalPost('node/' . $node->nid, $form, t('OK'));
  $text = $node->body[LANGUAGE_NONE][0]['value'];
  $this
    ->assertText($text, "User with right permission can access a protected node with right password", $this->group);
}