/[drupal]/contributions/modules/troll/troll.test
ViewVC logotype

Contents of /contributions/modules/troll/troll.test

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Mon Mar 2 06:01:13 2009 UTC (8 months, 3 weeks ago) by deekayen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +3 -2 lines
File MIME type: text/x-php
test the simpletest user name on a user page string test
1 <?php
2 // $Id: troll.test,v 1.1.2.1 2009/02/11 20:01:15 deekayen Exp $
3
4 class TrollFunctionalTest extends DrupalWebTestCase {
5 function getInfo() {
6 return array(
7 'name' => 'Troll unit tests',
8 'description' => "Tests the expected return values of functions.",
9 'group' => 'Troll'
10 );
11 }
12
13 function setUp() {
14 parent::setUp('troll');
15 }
16
17 function testTrollLongIP() {
18 $test_urls = array(
19 '127.0.0.1' => 2130706433,
20 );
21
22 foreach ($test_urls as $ip => $result) {
23 $this->assertTrue(_troll_longip($ip) == $result, t('!original was converted to !new', array('!original' => $ip, '!new' => $result)));
24 }
25 }
26
27 function testTrollPerms() {
28 $perms = troll_perm();
29 $this->assertTrue(is_array($perms) && sizeof($perms) > 0, t('Troll has special permissions.'));
30 }
31 }
32
33 class TrollWebTestCase extends DrupalWebTestCase {
34 function getInfo() {
35 return array(
36 'name' => 'Troll interface',
37 'description' => "Test the Troll interface.",
38 'group' => 'Troll'
39 );
40 }
41
42 function setUp() {
43 parent::setUp('troll');
44 }
45
46 function testTrollNonPrivInterfaceGrants() {
47 $non_priv_user = $this->drupalCreateUser();
48 $this->drupalLogin($non_priv_user);
49 $this->drupalGet('admin/user/troll');
50 $this->assertResponse(403, t('Access denied to Troll administration page.'));
51 $this->drupalGet('admin/user/troll/search');
52 $this->assertResponse(403, t('Access denied to Troll administration page.'));
53 $this->drupalGet('admin/user/troll/search/view');
54 $this->assertResponse(403, t('Access denied to Troll administration page.'));
55 $this->drupalGet('admin/user/troll/search/block');
56 $this->assertResponse(403, t('Access denied to Troll administration page.'));
57 $this->drupalGet('admin/user/troll/ip_ban');
58 $this->assertResponse(403, t('Access denied to Troll administration page.'));
59 $this->drupalGet('admin/user/troll/ip_ban/edit');
60 $this->assertResponse(403, t('Access denied to Troll administration page.'));
61 $this->drupalGet('admin/user/troll/ip_ban/user');
62 $this->assertResponse(403, t('Access denied to Troll administration page.'));
63 $this->drupalGet('admin/user/troll/ip_ban/delete');
64 $this->assertResponse(403, t('Access denied to Troll administration page.'));
65 $this->drupalGet('admin/user/troll/ip_blacklist');
66 $this->assertResponse(403, t('Access denied to Troll administration page.'));
67 $this->drupalGet('admin/user/troll/ip_blacklist/summary');
68 $this->assertResponse(403, t('Access denied to Troll administration page.'));
69 $this->drupalGet('admin/user/troll/ip_blacklist/punishment');
70 $this->assertResponse(403, t('Access denied to Troll administration page.'));
71 $this->drupalGet('admin/user/troll/ip_blacklist/import');
72 $this->assertResponse(403, t('Access denied to Troll administration page.'));
73 $this->drupalGet('admin/user/troll/ip_blacklist/search');
74 $this->assertResponse(403, t('Access denied to Troll administration page.'));
75 $this->drupalGet('admin/user/troll/ip_blacklist/deleteblack');
76 $this->assertResponse(403, t('Access denied to Troll administration page.'));
77 $this->drupalGet('admin/user/troll/ip_blacklist/whitelist');
78 $this->assertResponse(403, t('Access denied to Troll administration page.'));
79 $this->drupalGet('admin/user/troll/ip_blacklist/deletewhite');
80 $this->assertResponse(403, t('Access denied to Troll administration page.'));
81 $this->drupalGet('admin/user/troll/settings');
82 $this->assertResponse(403, t('Access denied to Troll administration page.'));
83 $this->drupalGet('user');
84 $this->assertNoLink('Troll Track');
85 $this->drupalGet('user/logout');
86 }
87
88 function testTrollPrivInterfaceGrants() {
89 $permissions = array('administer troll', 'administer site configuration');
90 $priv_user = $this->drupalCreateUser($permissions);
91 $this->drupalLogin($priv_user);
92 $this->drupalGet('admin/user/troll');
93 $this->assertResponse(200, t('Access granted to Troll administration page.'));
94
95 $this->assertLink('Search Users');
96 $this->assertLink('IP Banning');
97 $this->assertLink('Blacklists');
98 $this->assertLink('Settings');
99 $this->assertText('Search Users', t('Fieldset found'));
100 $this->assertFieldByName('username', '');
101 $this->assertFieldByName('mail', '');
102 $this->assertFieldByName('ip_address', '');
103 $this->assertFieldByName('date_created', '');
104
105 $this->drupalGet('admin/user/troll');
106 $this->assertResponse(200, t('Access granted to Troll administration page.'));
107 $this->drupalGet('admin/user/troll/search');
108 $this->assertResponse(200, t('Access granted to Troll administration page.'));
109 $this->drupalGet('admin/user/troll/ip_ban');
110 $this->assertResponse(200, t('Access granted to Troll administration page.'));
111
112 $this->assertText('Add IP Ban', t('Fieldset found'));
113 $this->assertFieldByName('ip_address', '');
114 $this->assertFieldByName('domain_name', '');
115 $this->assertField('expires');
116 $this->assertField('month');
117 $this->assertField('day');
118 $this->assertField('year');
119 $this->assertText('Banned IPs', t('Fieldset found'));
120
121 $this->drupalGet('admin/user/troll/ip_blacklist');
122 $this->assertResponse(200, t('Access granted to Troll administration page.'));
123
124 $this->assertLink('Summary');
125 $this->assertLink('Visitor Punishment');
126 $this->assertLink('Import Blacklist');
127 $this->assertLink('Search Blacklisted IPs');
128 $this->assertLink('Whitelist');
129 $this->assertText('address blocks filtered');
130
131 $this->drupalGet('admin/user/troll/ip_blacklist/summary');
132 $this->assertResponse(200, t('Access granted to Troll administration page.'));
133 $this->drupalGet('admin/user/troll/ip_blacklist/punishment');
134 $this->assertResponse(200, t('Access granted to Troll administration page.'));
135
136 $this->assertField('stutter');
137 $this->assertField('mod_requests');
138 $this->assertField('alt_page');
139 $this->assertField('alt_url');
140
141 $this->drupalGet('admin/user/troll/ip_blacklist/import');
142 $this->assertResponse(200, t('Access granted to Troll administration page.'));
143
144 $this->assertField('truncate_list');
145 $this->assertField('select_list');
146 $this->assertField('custom_list');
147
148 $this->drupalGet('admin/user/troll/ip_blacklist/search');
149 $this->assertResponse(200, t('Access granted to Troll administration page.'));
150
151 $this->assertField('ip_address');
152
153 $this->drupalGet('admin/user/troll/ip_blacklist/whitelist');
154 $this->assertResponse(200, t('Access granted to Troll administration page.'));
155
156 $this->assertField('whitelist_addr1');
157 $this->assertField('whitelist_addr2');
158
159 $this->drupalGet('admin/user/troll/settings');
160 $this->assertResponse(200, t('Access granted to Troll administration page.'));
161
162 $this->assertField('troll_enable_ip_ban');
163 $this->assertField('troll_ip_ban_redirect');
164 $this->assertField('troll_block_role');
165
166 $this->drupalGet('user');
167 $this->assertLink('Troll Track');
168 $this->clickLink('Troll Track');
169
170 $this->assertText("Account Details for $priv_user->name");
171 $this->assertLink('Block User');
172 $this->assertLink('Ban IP');
173 $this->assertText($priv_user->mail);
174 $this->assertLink($priv_user->name);
175 $this->assertText('IP History');
176 $this->assertText('Status');
177 $this->assertText('Last Access');
178 $this->assertText('First Access');
179 $this->assertText('Host Information');
180 $this->assertText('Recent Posts');
181 $this->drupalGet('user/logout');
182 }
183
184 }

  ViewVC Help
Powered by ViewVC 1.1.2