4

SimpleTest: checking access to a path

http://drupal.org

I'm building out my module using SimpleTest and need to write a test to verify that access to a menu path is correctly restricted. Based on the Lullabot tutorial, I'm figuring the correct method is to create a user without the necessary permissions, log in, call the get() method, and test the returned text for Access Denied. Something like ..

<?php
  function testAdminAccess() {
    $user = drupalCreateUserRolePerm();
    $this->drupalLoginUser($user);
    $url = url("admin/settings/post_reminder", array('absolute' => TRUE));
    $contents = $this->get($url);
    $this->assertNoText($contents, t('Access Denied'));
  }
?>

Is this the way or is there a better means; maybe something that can test the html code returned? I've been looking in the API function reference in the handbook, but it doesn't appear to contain all the available methods.

Many thanks,
Barrett

Read »
Created by Dplanet 2 years 42 weeks ago
Category: Modules   Tags:

PSD to Drupal Theme

Drupal Development

Module Development

Get an Estimate

Tags for SimpleTest: checking access to a path

Recent comments