protected_node.statistics.test in Protected Node 7
Same filename and directory in other branches
Test protected node statistics overview.
File
tests/protected_node.statistics.testView source
<?php
/**
* @file
* Test protected node statistics overview.
*/
/**
* Test protected node statistics overview.
*/
class ProtectedNodeStatistics extends ProtectedNodeBaseTestCase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Protected node statistic overview',
'description' => "This tests statistics overview",
'group' => 'Protected Node',
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
// Generate random password.
$this->global_password = $this
->randomName(10);
// Log in an Admin.
$this
->drupalLogin($this->adminUser);
// Submit the configuration form.
$protected_node_settings = array(
'protected_node_use_global_password' => PROTECTED_NODE_PER_NODE_AND_GLOBAL_PASSWORD,
'protected_node_global_password_field[pass1]' => $this->global_password,
'protected_node_global_password_field[pass2]' => $this->global_password,
);
$this
->drupalPost('admin/config/content/protected_node', $protected_node_settings, t('Save configuration'));
}
/**
* Test function.
*
* Test the total number of nodes.
*/
public function testTotal() {
// Add a new page node.
$node_data = array(
'title' => $this
->randomName(8),
'body[und][0][value]' => $this
->randomName(32),
);
$this
->drupalPost('node/add/page', $node_data, t('Save'));
// Go to the configuration page.
$this
->drupalGet('admin/config/content/protected_node');
$this
->assertRaw('<td>Total nodes</td><td style="text-align:right">1</td>', 'The total number of nodes is right.');
}
/**
* Test function.
*
* Test the total number of unprotected/protected nodes.
*/
public function testUnprotectedProtected() {
// Add a new page node that is not protected.
$node_data = array(
'title' => $this
->randomName(8),
'body[und][0][value]' => $this
->randomName(32),
);
$this
->drupalPost('node/add/page', $node_data, t('Save'));
// Add a new page node that is protected.
$node_data = array(
'title' => $this
->randomName(8),
'body[und][0][value]' => $this
->randomName(32),
'protected_node_is_protected' => TRUE,
);
$this
->drupalPost('node/add/page', $node_data, t('Save'));
// Go to the configuration page.
$this
->drupalGet('admin/config/content/protected_node');
$this
->assertRaw('<td>Total nodes</td><td style="text-align:right">2</td>', 'The total number of nodes is right.');
$this
->assertRaw('<td>Unprotected nodes</td><td style="text-align:right">1</td>', 'The total number of unprotected nodes is right.');
$this
->assertRaw('<td>Protected nodes</td><td style="text-align:right">1</td>', 'The total number of protected nodes is right.');
}
/**
* Test function.
*
* Test the total number of showing/hiding title nodes.
*/
public function testShowingHidingTitle() {
// Add a new page node that is protected showing title.
$node_data = array(
'title' => $this
->randomName(8),
'body[und][0][value]' => $this
->randomName(32),
'protected_node_is_protected' => TRUE,
'protected_node_show_title' => TRUE,
);
$this
->drupalPost('node/add/page', $node_data, t('Save'));
// Add a new page node that is protected not showing title.
$node_data = array(
'title' => $this
->randomName(8),
'body[und][0][value]' => $this
->randomName(32),
'protected_node_is_protected' => TRUE,
'protected_node_show_title' => FALSE,
);
$this
->drupalPost('node/add/page', $node_data, t('Save'));
// Go to the configuration page.
$this
->drupalGet('admin/config/content/protected_node');
$this
->assertRaw('<td>Total nodes</td><td style="text-align:right">2</td>', 'The total number of nodes is right.');
$this
->assertRaw('<td>Unprotected nodes</td><td style="text-align:right">0</td>', 'The total number of unprotected nodes is right.');
$this
->assertRaw('<td>Protected nodes</td><td style="text-align:right">2</td>', 'The total number of protected nodes is right.');
$this
->assertRaw('<td>Showing title</td><td style="text-align:right">1</td>', 'The total number of protected nodes showing title is right.');
$this
->assertRaw('<td>Hiding title</td><td style="text-align:right">1</td>', 'The total number of protected nodes hiding title is right.');
}
/**
* Test function.
*
* Test the total number of nodes protected by global/node passwords.
*/
public function testGlobalNodePassword() {
// Add a new page node that is protected by the global password.
$node_data = array(
'title' => $this
->randomName(8),
'body[und][0][value]' => $this
->randomName(32),
'protected_node_is_protected' => TRUE,
);
$this
->drupalPost('node/add/page', $node_data, t('Save'));
// Add a new page node that is protected by a node password.
$password = $this
->randomName(8);
$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,
);
$this
->drupalPost('node/add/page', $node_data, t('Save'));
// Go to the configuration page.
$this
->drupalGet('admin/config/content/protected_node');
$this
->assertRaw('<td>Total nodes</td><td style="text-align:right">2</td>', 'The total number of nodes is right.');
$this
->assertRaw('<td>Unprotected nodes</td><td style="text-align:right">0</td>', 'The total number of unprotected nodes is right.');
$this
->assertRaw('<td>Protected nodes</td><td style="text-align:right">2</td>', 'The total number of protected nodes is right.');
$this
->assertRaw('<td>Global passwords</td><td style="text-align:right">1</td>', 'The total number of nodes protected by a global password is right.');
$this
->assertRaw('<td>Node passwords</td><td style="text-align:right">1</td>', 'The total number of nodes protected by a node password is right.');
}
}
Classes
Name | Description |
---|---|
ProtectedNodeStatistics | Test protected node statistics overview. |