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

Contents of /contributions/modules/admin_links/admin_links.test

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


Revision 1.2 - (show annotations) (download) (as text)
Mon Nov 3 22:19:19 2008 UTC (12 months, 3 weeks ago) by davereid
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +85 -0 lines
File MIME type: text/x-php
- New files sync to HEAD
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Unit tests for the admin_links module.
7 */
8
9 class AdminLinksTestCase extends DrupalWebTestCase {
10
11 /**
12 * Implementation of getInfo().
13 */
14 function getInfo() {
15 return array(
16 'name' => t('Admin links functionality'),
17 'description' => t('Test admin links module functionality.'),
18 'group' => t('Admin links'),
19 );
20 }
21
22 /**
23 * Implementation of setUp().
24 */
25 function setUp() {
26 parent::setUp('admin_links');
27 }
28
29 function testAdminLinks() {
30
31 // Create users
32 $this->user_admin = $this->drupalCreateUser(array('access content', 'administer nodes', 'administer site configuration'));
33 $this->user_edit = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content'));
34 $this->user_delete = $this->drupalCreateUser(array('access content', 'create page content', 'delete own page content'));
35
36 // Create nodes
37 $this->nodes = array();
38 $this->nodes[1] = $this->drupalCreateNode(array('promote' => 1, 'uid' => $this->user_admin->uid));
39 $this->nodes[2] = $this->drupalCreateNode(array('promote' => 1, 'uid' => $this->user_edit->uid));
40 $this->nodes[3] = $this->drupalCreateNode(array('promote' => 1, 'uid' => $this->user_delete->uid));
41
42 // Set variables
43 variable_set('admin_links_edit', 1);
44 variable_set('admin_links_delete', 1);
45 variable_set('admin_links_universaledit', 1);
46
47 // Login user
48 $this->drupalLogin($this->user_admin);
49
50
51
52
53 $edit = array(
54 'admin_links_edit' => NULL,
55 'admin_links_delete' => NULL,
56 'admin_links_universaledit' => NULL,
57 );
58 $this->drupalPost('admin/settings/admin-links', $edit, t('Save configuration'));
59
60 $this->drupalGet('node');
61 foreach ($this->nodes as $node) {
62 $this->assertNoRaw($this->getEditLink($node->nid), t('Edit link not found.'));
63 $this->assertNoRaw($this->getDeleteLink($node->nid), t('Delete link not found.'));
64 }
65 $this->assertTrue(TRUE, htmlspecialchars($this->_content));
66
67 foreach ($this->nodes as $node) {
68 $this->drupalGet('node/'. $node->nid);
69 $this->assertNoRaw($this->getUniversalEditLink($node->nid), t('Universal edit link not found.'));
70 }
71 }
72
73 function getUniversalEditLink($nid) {
74 return '<link rel="alternate" type="application/x-wiki" title="'. t('Edit this page') .'" href="'. url("node/$nid/edit", array('absolute' => TRUE)) . '" />';
75 }
76
77 function getEditLink($nid) {
78 return '<a href="'. url("node/$nid/edit", array('query' => 'destination=node')) .'">'. t('Edit') .'</a>';
79 }
80
81 function getDeleteLink($nid) {
82 return '<a href="'. url("node/$nid/delete", array('query' => 'destination=node')) .'">'. t('Delete') .'</a>';
83 }
84
85 }

  ViewVC Help
Powered by ViewVC 1.1.2