1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class ForumMemberProfileTest extends FunctionalTest { |
|
|
|
|
4
|
|
|
|
5
|
|
|
static $fixture_file = "forum/tests/ForumTest.yml"; |
|
|
|
|
6
|
|
|
static $use_draft_site = true; |
|
|
|
|
7
|
|
|
|
8
|
|
|
function testRegistrationWithHoneyPot() { |
|
|
|
|
9
|
|
|
$origHoneypot = ForumHolder::$use_honeypot_on_register; |
10
|
|
|
$origSpamprotection = ForumHolder::$use_spamprotection_on_register; |
11
|
|
|
|
12
|
|
|
ForumHolder::$use_spamprotection_on_register = false; |
13
|
|
|
|
14
|
|
|
ForumHolder::$use_honeypot_on_register = false; |
15
|
|
|
$response = $this->get('ForumMemberProfile/register'); |
16
|
|
|
$this->assertNotContains('RegistrationForm_username', $response->getBody(), 'Honeypot is disabled by default'); |
17
|
|
|
|
18
|
|
|
ForumHolder::$use_honeypot_on_register = true; |
19
|
|
|
$response = $this->get('ForumMemberProfile/register'); |
20
|
|
|
$this->assertContains('RegistrationForm_username', $response->getBody(), 'Honeypot can be enabled'); |
21
|
|
|
|
22
|
|
|
// TODO Will fail if Member is decorated with further *required* fields, |
23
|
|
|
// through updateForumFields() or updateForumValidator() |
|
|
|
|
24
|
|
|
$baseData = array( |
25
|
|
|
'Password' => array( |
26
|
|
|
'_Password' => 'text', |
27
|
|
|
'_ConfirmPassword' => 'text' |
28
|
|
|
), |
29
|
|
|
"Nickname" => 'test', |
30
|
|
|
"Email" => '[email protected]', |
31
|
|
|
); |
32
|
|
|
|
33
|
|
|
$invalidData = array_merge($baseData, array('action_doregister' => 1, 'username' => 'spamtastic')); |
34
|
|
|
$response = $this->post('ForumMemberProfile/RegistrationForm', $invalidData); |
35
|
|
|
$this->assertEquals(403, $response->getStatusCode()); |
|
|
|
|
36
|
|
|
|
37
|
|
|
$validData = array_merge($baseData, array('action_doregister' => 1)); |
38
|
|
|
$response = $this->post('ForumMemberProfile/RegistrationForm', $validData); |
39
|
|
|
// Weak check (registration might still fail), but good enough to know if the honeypot is working |
40
|
|
|
$this->assertEquals(200, $response->getStatusCode()); |
|
|
|
|
41
|
|
|
|
42
|
|
|
ForumHolder::$use_honeypot_on_register = $origHoneypot; |
43
|
|
|
ForumHolder::$use_spamprotection_on_register = $origSpamprotection; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
function testMemberProfileSuspensionNote() { |
|
|
|
|
47
|
|
|
SS_Datetime::set_mock_now('2011-10-10'); |
48
|
|
|
|
49
|
|
|
$normalMember = $this->objFromFixture('Member', 'test1'); |
50
|
|
|
$this->loginAs($normalMember); |
51
|
|
|
$response = $this->get('ForumMemberProfile/edit/' . $normalMember->ID); |
52
|
|
|
|
53
|
|
|
$this->assertNotContains( |
54
|
|
|
_t('ForumRole.SUSPENSIONNOTE'), |
55
|
|
|
$response->getBody(), |
56
|
|
|
'Normal profiles don\'t show suspension note' |
57
|
|
|
); |
58
|
|
|
|
59
|
|
|
$suspendedMember = $this->objFromFixture('Member', 'suspended'); |
60
|
|
|
$this->loginAs($suspendedMember); |
61
|
|
|
$response = $this->get('ForumMemberProfile/edit/' . $suspendedMember->ID); |
62
|
|
|
$this->assertContains( |
63
|
|
|
_t('ForumRole.SUSPENSIONNOTE'), |
64
|
|
|
$response->getBody(), |
65
|
|
|
'Suspended profiles show suspension note' |
66
|
|
|
); |
67
|
|
|
|
68
|
|
|
SS_Datetime::clear_mock_now(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
function testMemberProfileDisplays() { |
|
|
|
|
72
|
|
|
/* Get the profile of a secretive member */ |
73
|
|
|
$this->get('ForumMemberProfile/show/' . $this->idFromFixture('Member', 'test1')); |
74
|
|
|
|
75
|
|
|
/* Check that it just contains the bare minimum |
76
|
|
|
|
77
|
|
|
Commented out by wrossiter since this was breaking with custom themes. A test like this should not fail |
78
|
|
|
because of a custom theme. Will reenable these tests when we tackle the new Member functionality |
79
|
|
|
|
80
|
|
|
$this->assertExactMatchBySelector("div#UserProfile label", array( |
81
|
|
|
"Nickname:", |
82
|
|
|
"Number of posts:", |
83
|
|
|
"Forum ranking:", |
84
|
|
|
"Avatar:", |
85
|
|
|
)); |
86
|
|
|
$this->assertExactMatchBySelector("div#UserProfile p", array( |
87
|
|
|
'test1', |
88
|
|
|
'5', |
89
|
|
|
'n00b', |
90
|
|
|
'', |
91
|
|
|
)); |
92
|
|
|
|
93
|
|
|
/* Get the profile of a public member */ |
94
|
|
|
$this->get('ForumMemberProfile/show/' . $this->idFromFixture('Member', 'test2')); |
95
|
|
|
|
96
|
|
|
/* Check that it just contains everything |
|
|
|
|
97
|
|
|
|
98
|
|
|
$this->assertExactMatchBySelector("div#UserProfile label", array( |
99
|
|
|
"Nickname:", |
100
|
|
|
'First Name:', |
101
|
|
|
'Surname:', |
102
|
|
|
'Email:', |
103
|
|
|
'Occupation:', |
104
|
|
|
'Country:', |
105
|
|
|
'Number of posts:', |
106
|
|
|
'Forum ranking:', |
107
|
|
|
'Avatar:' |
108
|
|
|
)); |
109
|
|
|
$this->assertExactMatchBySelector("div#UserProfile p", array( |
110
|
|
|
'test2', |
111
|
|
|
'Test', |
112
|
|
|
'Two', |
113
|
|
|
'', |
114
|
|
|
'OtherUser', |
115
|
|
|
'Australia', |
116
|
|
|
'8', |
117
|
|
|
'l33t', |
118
|
|
|
'', |
119
|
|
|
)); |
120
|
|
|
*/ |
121
|
|
|
} |
122
|
|
|
} |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.