How to test if user is denied access when her role has no "access content" Wanting to test that only users with "access content" have access:

public function testOnlyAccessContentAccessible() {
  $web_user = $this-&gt;drupalCreateUser();
  $this-&gt;drupalLogin($web_user);
  $this-&gt;drupalGet("foo");
  $this-&gt;assertResponse(403);
}


The module under test, relevant hook_menu-entry:

$items['foo'] = array(
  'title' =&gt; 'Foo',
  'page callback' =&gt; 'foo',
  'access arguments' =&gt; array("access content"),
  'expanded' =&gt; TRUE,
);


What is wrong here? My drupalCreateUser has not recieved an array with permissions, so it did not receive the "access content" permission either; yet Drupal hands out this permission by default, so I guess this is a permission that is "default" when nothing is posted. 

So, how to check that only users with permission "access content" can access a page?
I recommend saving out your permissions using Features and then loading your custom feature in your test. By doing that, you can test out your configuration settings.

If you really just want to turn programmatically create a user that does not have the 'access content' permission, try this before you create your $web_user:

user_role_revoke_permissions(1, array('access content'));


This will revoke the 'access content' permission for anonymous users (role 1). See http://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_role_revoke_permissions/7 for more help.