'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('Total nodes1', '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('Total nodes2', 'The total number of nodes is right.'); $this->assertRaw('Unprotected nodes1', 'The total number of unprotected nodes is right.'); $this->assertRaw('Protected nodes1', '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('Total nodes2', 'The total number of nodes is right.'); $this->assertRaw('Unprotected nodes0', 'The total number of unprotected nodes is right.'); $this->assertRaw('Protected nodes2', 'The total number of protected nodes is right.'); $this->assertRaw('Showing title1', 'The total number of protected nodes showing title is right.'); $this->assertRaw('Hiding title1', '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('Total nodes2', 'The total number of nodes is right.'); $this->assertRaw('Unprotected nodes0', 'The total number of unprotected nodes is right.'); $this->assertRaw('Protected nodes2', 'The total number of protected nodes is right.'); $this->assertRaw('Global passwords1', 'The total number of nodes protected by a global password is right.'); $this->assertRaw('Node passwords1', 'The total number of nodes protected by a node password is right.'); } }