public function InternalNodesTypeCase::testContentTypeSettings in Internal Nodes 7
File
- tests/
internal_nodes_ct.test, line 72 - SimpleTest for Internal nodes
Class
- InternalNodesTypeCase
- @file SimpleTest for Internal nodes
Code
public function testContentTypeSettings() {
// Login as admin
$this
->drupalLogin($this->admin_user);
// Check access to untouched node
$this
->drupalGet('node/' . $this->node->nid);
$this
->assertText($this->node->title, 'Unmodified node accessible to role.');
// Set content type 404 to Not Found
$edit = array(
'internal_nodes_action' => 404,
);
$this
->drupalPost('admin/structure/types/manage/' . $this->ctype_404->type, $edit, t('Save content type'));
$this
->assertText(t('has been updated.'), '404 not found set.');
// Check access to node 404
$this
->drupalGet('node/' . $this->node_404->nid);
$this
->assertText($this->node_404->title, 'Node 404 accessible to role with permission.');
// Set content type 403 to access denied.
$edit = array(
'internal_nodes_action' => 403,
);
$this
->drupalPost('admin/structure/types/manage/' . $this->ctype_403->type, $edit, t('Save content type'));
$this
->assertText(t('has been updated.'), '403 access denied set.');
// Check access to node 403
$this
->drupalGet('node/' . $this->node_403->nid);
$this
->assertText($this->node_403->title, 'Node 403 accessible to role with permission.');
// Set content type 301 to redirect.
$edit = array(
'internal_nodes_action' => 301,
);
$this
->drupalPost('admin/structure/types/manage/' . $this->ctype_301->type, $edit, t('Save content type'));
$edit = array(
'internal_nodes_url' => 'node/1',
);
// Set redirect to node1/
$this
->drupalPost('admin/structure/types/manage/' . $this->ctype_301->type, $edit, t('Save content type'));
$this
->assertText(t('has been updated.'), '301 redirect URL set.');
// Check access to node 301
$this
->drupalGet('node/' . $this->node_301->nid);
$this
->assertText($this->node_301->title, 'Node 301 accessible to role with permission.');
// Switch user to anonymous user
$this
->drupalLogout();
// Check access to untouched node
$this
->drupalGet('node/' . $this->node->nid);
$this
->assertText($this->node->title, 'Unmodified node accessible to role without permission.');
// Check access to node 404
$this
->drupalGet('node/' . $this->node_404->nid);
$this
->assertText(t('Page not found'), 'Node not accessible to role without permission.');
// Check access to node 403
$this
->drupalGet('node/' . $this->node_403->nid);
$this
->assertText(t('Access denied'), 'Node not accessible to role without permission.');
// Check access to node 301
$this
->drupalGet('node/' . $this->node_301->nid);
$this
->assertText($this->node->title, 'Node 301 redirects to node #1 for role without permission.');
// Login as admin.
$this
->drupalLogin($this->admin_user);
// Enable outbound URL alter globally.
$edit = array(
'internal_nodes_outbound_alter' => TRUE,
);
$this
->drupalPost('admin/config/search/internal-nodes', $edit, t('Save configuration'));
$this
->assertText(t('The configuration options have been saved.'), 'Outbound URL config saved.');
// Enable outbound URL alter for 301 content type
$edit = array(
'internal_nodes_outbound_alter' => TRUE,
);
$this
->drupalPost('admin/structure/types/manage/' . $this->ctype_301->type, $edit, t('Save content type'));
// Go to home page where node_301 has been promoted
$this
->drupalGet('');
// With outbound URL alter enabled, and permission enabled, the link
// should NOT point to node/1 instead of node/3.
$this
->assertLinkByHref('node/4', 0, 'Link to node/4 continues pointing to node/4.');
// Switch user to anonymous user
$this
->drupalLogout();
// Go to home page where node_301 has been promoted
$this
->drupalGet('');
// With outbound URL alter enabled, and permission disabled, the link
// should point to node/1 instead of node/4
$this
->assertLinkByHref('node/1', 0, 'Link to node/4 has been changed to node/1.');
// Login as regular user.
$this
->drupalLogin($this->regular_user);
// Check access to node 403
$this
->drupalGet('node/' . $this->node_403->nid);
$this
->assertText(t('Access denied'), 'Node not accessible to role without permission.');
// Check access to node 403 edit
$this
->drupalGet('node/' . $this->node_403->nid . '/edit');
$this
->assertText($this->node_403->title, 'Node edit accessible to role with permission.');
// Check access to node 403 delete
$this
->drupalGet('node/' . $this->node_403->nid . '/delete');
$this
->assertText($this->node_403->title, 'Node delete accessible to role with permission.');
}