1 |
13c3c9b4
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Unit tests for advanced_forum.module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Class AfSimpleAPITest
|
10 |
|
|
*/
|
11 |
|
|
class AfSimpleAPITest extends DrupalUnitTestCase {
|
12 |
|
|
|
13 |
|
|
public static function getInfo() {
|
14 |
|
|
return array(
|
15 |
|
|
'name' => 'Advanced Forum API sanity checks',
|
16 |
|
|
'description' => 'Test the simple API functions in the public Advanced Forum API.',
|
17 |
|
|
'group' => 'Advanced Forum',
|
18 |
|
|
);
|
19 |
|
|
}
|
20 |
|
|
|
21 |
|
|
public function setUp() {
|
22 |
|
|
drupal_load('module', 'advanced_forum');
|
23 |
|
|
parent::setUp();
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
/**
|
27 |
|
|
* Implements unit tests.
|
28 |
|
|
*/
|
29 |
|
|
public function testAfFunctions() {
|
30 |
|
|
|
31 |
|
|
}
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
/**
|
35 |
|
|
* Class testAfFormsTestCase
|
36 |
|
|
*/
|
37 |
|
|
class testAfFormsTestCase extends DrupalWebTestCase {
|
38 |
|
|
protected $privileged_user;
|
39 |
|
|
|
40 |
|
|
public static function getInfo() {
|
41 |
|
|
return array(
|
42 |
|
|
'name' => 'Advanced Forum Forms',
|
43 |
|
|
'description' => 'Advanced Forum Forms WebTesting.',
|
44 |
|
|
'group' => 'Advanced Forum',
|
45 |
|
|
);
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
/**
|
49 |
|
|
* Implement setUp() method.
|
50 |
|
|
*/
|
51 |
|
|
public function setUp() {
|
52 |
|
|
// Enable any modules required for the test.
|
53 |
|
|
parent::setUp('advanced_forum');
|
54 |
|
|
// Create and log in our user. The user has the arbitrary privilege
|
55 |
|
|
// 'extra special edit any simpletest_example' which the code uses
|
56 |
|
|
// to grant access.
|
57 |
|
|
$this->privileged_user = $this->drupalCreateUser(
|
58 |
|
|
array('administer site configuration')
|
59 |
|
|
);
|
60 |
|
|
$this->drupalLogin($this->privileged_user);
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
/**
|
64 |
|
|
* Implements admin form save.
|
65 |
|
|
*/
|
66 |
|
|
public function testAfSaveConfig() {
|
67 |
|
|
$this->privileged_user = $this->drupalCreateUser(
|
68 |
|
|
array(
|
69 |
|
|
'administer advanced forum',
|
70 |
|
|
'view forum statistics',
|
71 |
|
|
'view last edited notice'
|
72 |
|
|
)
|
73 |
|
|
);
|
74 |
|
|
$this->drupalLogin($this->privileged_user);
|
75 |
|
|
|
76 |
ba09eb79
|
Assos Assos
|
$edit = array();
|
77 |
|
|
|
78 |
13c3c9b4
|
Assos Assos
|
// Let's test all admin forms.
|
79 |
|
|
$this->drupalPost(
|
80 |
|
|
'admin/config/content/advanced-forum',
|
81 |
|
|
$edit,
|
82 |
|
|
t('Save configuration')
|
83 |
|
|
);
|
84 |
|
|
|
85 |
|
|
$this->assertText(t('The configuration options have been saved.'));
|
86 |
|
|
|
87 |
|
|
$this->drupalGet('forum', $edit);
|
88 |
|
|
$this->drupalGet('forum/active', $edit);
|
89 |
|
|
$this->drupalGet('forum/unanswered', $edit);
|
90 |
|
|
$this->drupalPost('forum/new', $edit, t('Apply'));
|
91 |
|
|
$this->drupalPost('forum/unanswered', $edit, t('Apply'));
|
92 |
|
|
$this->drupalPost('forum/active', $edit, t('Apply'));
|
93 |
|
|
$edit1 = array('forum' => 1);
|
94 |
|
|
$this->drupalPost('forum/new', $edit1, t('Apply'));
|
95 |
|
|
$this->drupalPost('forum/unanswered', $edit1, t('Apply'));
|
96 |
|
|
$this->drupalPost('forum/active', $edit1, t('Apply'));
|
97 |
|
|
$this->drupalGet('forum/markasread', $edit);
|
98 |
|
|
$edit2 = array('forum' => 'All');
|
99 |
|
|
$this->drupalPost('forum/new', $edit2, t('Apply'));
|
100 |
|
|
$this->drupalPost('forum/unanswered', $edit2, t('Apply'));
|
101 |
|
|
$this->drupalPost('forum/active', $edit2, t('Apply'));
|
102 |
ba09eb79
|
Assos Assos
|
|
103 |
|
|
// Test the form to create forum with option to add fields from taxonomy term.
|
104 |
|
|
$edit3 = array(
|
105 |
|
|
'advanced_forum_forum_user_term_fields' => TRUE,
|
106 |
|
|
);
|
107 |
|
|
|
108 |
|
|
$this->drupalPost(
|
109 |
|
|
'admin/config/content/advanced-forum',
|
110 |
|
|
$edit3,
|
111 |
|
|
t('Save configuration')
|
112 |
|
|
);
|
113 |
|
|
|
114 |
|
|
$this->assertText(t('The configuration options have been saved.'));
|
115 |
|
|
|
116 |
|
|
$this->drupalGet('node/add/forum', array());
|
117 |
13c3c9b4
|
Assos Assos
|
}
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
/**
|
121 |
|
|
* Detect if we're running on PIFR testbot; skip intentional failure in that
|
122 |
|
|
* case. It happens that on the testbot the site under test is in a directory
|
123 |
|
|
* named 'checkout' or 'site_under_test'.
|
124 |
|
|
*
|
125 |
|
|
* @return boolean
|
126 |
|
|
* TRUE if running on testbot.
|
127 |
|
|
*/
|
128 |
|
|
public function runningOnTestbot() {
|
129 |
|
|
return (file_exists("../checkout") || file_exists("../site_under_test"));
|
130 |
|
|
}
|
131 |
|
|
} |