forked from easyting/ding_user_profile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathding_user_profile.test
More file actions
110 lines (91 loc) · 2.66 KB
/
ding_user_profile.test
File metadata and controls
110 lines (91 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* @file
* ding_user_profile.test
*/
/**
* Ding User Profile tests.
*/
class DingUserProfileTestCase extends DrupalWebTestCase {
/**
* Test user credentials.
*
* @var array
*/
protected $user_credentials = array(
'name' => '1111111118',
'pass' => '0000',
);
/**
* Test ALMA URL.
*
* @var string
*/
protected $alma_url = 'https://bibliotek.taarnby.dk:8000/alma/';
protected $fields = array(
'user_profile_field_alma_preferred_branch',
'user_profile_field_alma_interest_period',
'user_profile_field_alma_reservation_pause',
'user_profile_field_alma_mail',
'user_profile_field_alma_mobile_phone',
'user_profile_pass',
);
protected $post = array();
public static function getInfo() {
return array(
'name' => 'Ding User Profile tests',
'description' => 'Run tests for ding_user_profile.',
'group' => 'easyOPAC',
);
}
/**
* Set up test.
*/
public function setUp() {
$this->profile = 'ding2';
parent::setUp('alma', 'ding_user_profile');
// Disable, causes issues.
module_disable(array('cookiecontrol'));
// Test library URL.
variable_set('alma_base_url', $this->alma_url);
// Set test data.
foreach ($this->fields as $field) {
$this->post[$field] = $this->randomString();
}
}
public function testAdminUI() {
$admin = $this->drupalCreateUser(array(
'manage user profile features'
));
$this->drupalLogin($admin);
foreach ($this->post as $variable => $value) {
$value = variable_set($variable, $value);
}
$this->drupalGet('admin/config/ding/user_profile');
$this->assertText(t('The following fields will contain the description supplied below, however they might be hidden.'));
// Test saved data.
foreach ($this->post as $variable => $expected_value) {
$value = variable_get($variable);
$this->assertEqual($expected_value, $value, "Variable $variable has wrong value");
}
$this->drupalLogout();
}
public function testUserEditProfile() {
$this->drupalPost('user', $this->user_credentials, t('Log in'));
foreach ($this->post as $variable => $value) {
$value = variable_set($variable, $value);
}
$user = db_select('users', 'u')
->fields('u')
->orderBy('uid', 'desc')
->execute()
->fetchAssoc();
$this->drupalGet('user/' . $user['uid'] . '/view');
$this->assertText('Your user loan status');
$this->drupalGet('user/' . $user['uid'] . '/edit');
$this->assertText(t('Profile for Alma'));
foreach ($this->post as $key => $value) {
$this->assertText($value, "Field $key has no description.");
}
}
}