page_view.test in SimpleTest 6
File
tests/page_view.test
View source
<?php
class PageViewTest extends DrupalTestCase {
function get_info() {
return array(
'name' => t('Unauthorized node view'),
'desc' => t('Creates a node of type page and then an unpermissioned user attempts to edit the node, ' . 'before tries with an anonymous user. Asserts failure.' . '</ br>WARNING: This is based on default registered user permuissions (no administer nodes).'),
'group' => 'Node Tests',
);
}
function testPageView() {
global $user;
$node = $this
->drupalCreateNode();
$this
->assertNotNull(node_load($node->nid), 'Node created');
$html = $this
->drupalGet("node/{$node->nid}/edit");
$this
->assertResponse(403);
$test_user = $this
->drupalCreateUserRolePerm(array(
'access content',
));
$this
->drupalLoginUser($test_user);
$html = $this
->drupalGet("node/{$node->nid}/edit");
$this
->assertResponse(403);
$test_user = $this
->drupalCreateUserRolePerm(array(
'administer nodes',
));
node_delete($node->nid);
}
}