Project

General

Profile

Paste
Download (1.63 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / addthis / tests / AddThisPermissionsTestCase.test @ 2c8c2b87

1
<?php
2

    
3
class AddThisPermissionsTestCase extends DrupalWebTestCase
4
{
5

    
6
    public function setUp()
7
    {
8
        parent::setUp('addthis');
9
    }
10

    
11
    public static function getInfo()
12
    {
13
        return array(
14
            'name' => 'Permission tests',
15
            'description' => 'Permission tests for the AddThis-module.',
16
            'group' => 'AddThis',
17
        );
18
    }
19

    
20
    public function testUserWithoutAdministerAddThisPermissionShouldNotBeAllowedToAccessAddThisSystemSettings()
21
    {
22
        $this->drupalLogin($this->createAdminUserWithoutAddThisAdministrationPermission());
23
        $this->drupalGet('admin/config/system/addthis');
24
        $this->assertRaw(t('Access denied'),
25
            'A user without administer addthis permission should not be able to access AddThis system settings.');
26
    }
27

    
28
    public function testUserWithoutAdministerAdvancedAddThisPermissionShouldNotBeAllowedToAccessAdvancedAddThisSystemSettings()
29
    {
30
        $this->drupalLogin($this->createAdminUserWithoutAdvancedAddThisAdministrationPermission());
31
        $this->drupalGet('admin/config/system/addthis');
32
        $this->assertNoRaw(t('Advanced settings'),
33
            'A user without administer advanced addthis permission should not be able to access advanced AddThis system settings.');
34
    }
35

    
36
    private function createAdminUserWithoutAddThisAdministrationPermission()
37
    {
38
        return $this->drupalCreateUser(array('administer content types'));
39
    }
40

    
41
    private function createAdminUserWithoutAdvancedAddThisAdministrationPermission()
42
    {
43
        return $this->drupalCreateUser(array('administer content types', AddThis::PERMISSION_ADMINISTER_ADDTHIS));
44
    }
45
}