Completed
Push — master ( b765dd...e454df )
by Daniel
13:34 queued 10:58
created

ForumTest::testMarkAsSpamLink()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 44
Code Lines 24

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 44
rs 8.8571
cc 1
eloc 24
nc 1
nop 0
1
<?php
2
3
/**
4
 * @todo Write Tests for doPostMessageForm()
5
 */
6
class ForumTest extends FunctionalTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
    public static $fixture_file = "forum/tests/ForumTest.yml";
9
    public static $use_draft_site = true;
10
    
11 View Code Duplication
    public function testCanView()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
    {
13
        // test viewing not logged in
14
        if ($member = Member::currentUser()) {
15
            $member->logOut();
16
        }
17
        
18
        $public = $this->objFromFixture('Forum', 'general');
19
        $private = $this->objFromFixture('Forum', 'loggedInOnly');
20
        $limited = $this->objFromFixture('Forum', 'limitedToGroup');
21
        $noposting = $this->objFromFixture('Forum', 'noPostingForum');
22
        $inherited = $this->objFromFixture('Forum', 'inheritedForum');
23
        
24
        $this->assertTrue($public->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
        $this->assertFalse($private->canView());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
        $this->assertFalse($limited->canView());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        $this->assertTrue($noposting->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
        $this->assertFalse($inherited->canView());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
        
30
        // try logging in a member
31
        $member = $this->objFromFixture('Member', 'test1');
32
        $member->logIn();
33
        
34
        $this->assertTrue($public->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
        $this->assertTrue($private->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
        $this->assertFalse($limited->canView());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
        $this->assertTrue($noposting->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
        $this->assertFalse($inherited->canView());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
        
40
        // login as a person with access to restricted forum
41
        $member = $this->objFromFixture('Member', 'test2');
42
        $member->logIn();
43
        
44
        $this->assertTrue($public->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
        $this->assertTrue($private->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
        $this->assertTrue($limited->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
        $this->assertTrue($noposting->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
        $this->assertFalse($inherited->canView());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
50
        // Moderator should be able to view his own forums
51
        $member = $this->objFromFixture('Member', 'moderator');
52
        $member->logIn();
53
54
        $this->assertTrue($public->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
55
        $this->assertTrue($private->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
        $this->assertTrue($limited->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
        $this->assertTrue($noposting->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
58
        $this->assertTrue($inherited->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
59
    }
60
61 View Code Duplication
    public function testCanPost()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
    {
63
        // test viewing not logged in
64
        if ($member = Member::currentUser()) {
65
            $member->logOut();
66
        }
67
        
68
        $public = $this->objFromFixture('Forum', 'general');
69
        $private = $this->objFromFixture('Forum', 'loggedInOnly');
70
        $limited = $this->objFromFixture('Forum', 'limitedToGroup');
71
        $noposting = $this->objFromFixture('Forum', 'noPostingForum');
72
        $inherited = $this->objFromFixture('Forum', 'inheritedForum');
73
        
74
        $this->assertTrue($public->canPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
75
        $this->assertFalse($private->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
76
        $this->assertFalse($limited->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
77
        $this->assertFalse($noposting->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
78
        $this->assertFalse($inherited->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
79
        
80
        // try logging in a member
81
        $member = $this->objFromFixture('Member', 'test1');
82
        $member->logIn();
83
        
84
        $this->assertTrue($public->canPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
85
        $this->assertTrue($private->canPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
86
        $this->assertFalse($limited->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
87
        $this->assertFalse($noposting->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
88
        $this->assertFalse($inherited->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
89
        
90
        // login as a person with access to restricted forum
91
        $member = $this->objFromFixture('Member', 'test2');
92
        $member->logIn();
93
        
94
        $this->assertTrue($public->canPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
95
        $this->assertTrue($private->canPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
96
        $this->assertTrue($limited->canPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
97
        $this->assertFalse($noposting->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
98
        $this->assertFalse($inherited->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
99
100
        // Moderator should be able to view his own forums
101
        $member = $this->objFromFixture('Member', 'moderator');
102
        $member->logIn();
103
104
        $this->assertTrue($public->canPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
105
        $this->assertTrue($private->canPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
106
        $this->assertFalse($limited->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
107
        $this->assertFalse($noposting->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
108
        $this->assertFalse($inherited->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
109
    }
110
    
111
    public function testSuspended()
112
    {
113
        $private = $this->objFromFixture('Forum', 'loggedInOnly');
114
        $limited = $this->objFromFixture('Forum', 'limitedToGroup');
115
        $inheritedForum_loggedInOnly = $this->objFromFixture('Forum', 'inheritedForum_loggedInOnly');
116
        SS_Datetime::set_mock_now('2011-10-10 12:00:00');
117
            
118
        // try logging in a member suspendedexpired
119
        $suspendedexpired = $this->objFromFixture('Member', 'suspendedexpired');
120
        $this->assertFalse($suspendedexpired->IsSuspended());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
121
        $suspendedexpired->logIn();
122
        $this->assertTrue($private->canPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
123
        $this->assertTrue($limited->canPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
124
        $this->assertTrue($inheritedForum_loggedInOnly->canPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
125
        
126
        // try logging in a member suspended
127
        $suspended = $this->objFromFixture('Member', 'suspended');
128
        $this->assertTrue($suspended->IsSuspended());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
129
        $suspended->logIn();
130
        $this->assertFalse($private->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
131
        $this->assertFalse($limited->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
132
        $this->assertFalse($inheritedForum_loggedInOnly->canPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
133
    }
134
135 View Code Duplication
    public function testCanModerate()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
136
    {
137
        // test viewing not logged in
138
        if ($member = Member::currentUser()) {
139
            $member->logOut();
140
        }
141
        
142
        $public = $this->objFromFixture('Forum', 'general');
143
        $private = $this->objFromFixture('Forum', 'loggedInOnly');
144
        $limited = $this->objFromFixture('Forum', 'limitedToGroup');
145
        $noposting = $this->objFromFixture('Forum', 'noPostingForum');
146
        $inherited = $this->objFromFixture('Forum', 'inheritedForum');
147
        
148
        $this->assertFalse($public->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
149
        $this->assertFalse($private->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
150
        $this->assertFalse($limited->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
151
        $this->assertFalse($noposting->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
152
        $this->assertFalse($inherited->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
153
        
154
        // try logging in a member
155
        $member = $this->objFromFixture('Member', 'test1');
156
        $member->logIn();
157
        
158
        $this->assertFalse($public->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
159
        $this->assertFalse($private->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
160
        $this->assertFalse($limited->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
161
        $this->assertFalse($noposting->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
162
        $this->assertFalse($inherited->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
163
        
164
        // login as a person with access to restricted forum
165
        $member = $this->objFromFixture('Member', 'test2');
166
        $member->logIn();
167
        
168
        $this->assertFalse($public->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
169
        $this->assertFalse($private->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
170
        $this->assertFalse($limited->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
171
        $this->assertFalse($noposting->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
172
        $this->assertFalse($inherited->canModerate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
173
174
        // Moderator should be able to view his own forums
175
        $member = $this->objFromFixture('Member', 'moderator');
176
        $member->logIn();
177
178
        $this->assertTrue($public->canModerate());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
179
        $this->assertTrue($private->canModerate());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
180
        $this->assertTrue($limited->canModerate());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
181
        $this->assertTrue($noposting->canModerate());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
182
        $this->assertTrue($inherited->canModerate());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
183
    }
184
185
    public function testCanAttach()
186
    {
187
        $canAttach = $this->objFromFixture('Forum', 'general');
188
        $this->assertTrue($canAttach->canAttach());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
189
        
190
        $noAttach = $this->objFromFixture('Forum', 'forum1cat2');
191
        $this->assertFalse($noAttach->canAttach());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
192
    }
193
    
194
    public function testgetForbiddenWords()
195
    {
196
        $forum = $this->objFromFixture("Forum", "general");
197
        $f_controller = new Forum_Controller($forum);
198
        $this->assertEquals($f_controller->getForbiddenWords(), "shit,fuck");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
199
    }
200
    
201
    public function testfilterLanguage()
202
    {
203
        $forum =  $this->objFromFixture("Forum", "general");
204
        $f_controller = new Forum_Controller($forum);
205
        $this->assertEquals($f_controller->filterLanguage('shit'), "*");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
206
        
207
        $this->assertEquals($f_controller->filterLanguage('shit and fuck'), "* and *");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
208
        
209
        $this->assertEquals($f_controller->filterLanguage('hello'), "hello");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
210
    }
211
    
212
    public function testGetStickyTopics()
213
    {
214
        $forumWithSticky = $this->objFromFixture("Forum", "general");
215
        $stickies = $forumWithSticky->getStickyTopics();
216
        $this->assertEquals($stickies->Count(), '2');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
217
218
        // TODO: Sorts by Created, which is all equal on all Posts in test, and can't be overridden, so can't rely on order
219
        //$this->assertEquals($stickies->First()->Title, 'Global Sticky Thread');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
220
221
        $stickies = $forumWithSticky->getStickyTopics($include_global = false);
222
        $this->assertEquals($stickies->Count(), '1');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
223
        $this->assertEquals($stickies->First()->Title, 'Sticky Thread');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
224
        
225
        $forumWithGlobalOnly = $this->objFromFixture("Forum", "forum1cat2");
226
        $stickies = $forumWithGlobalOnly->getStickyTopics();
227
        $this->assertEquals($stickies->Count(), '1');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
228
        $this->assertEquals($stickies->First()->Title, 'Global Sticky Thread');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
229
        $stickies = $forumWithGlobalOnly->getStickyTopics($include_global = false);
230
        $this->assertEquals($stickies->Count(), '0');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
231
    }
232
    
233 View Code Duplication
    public function testTopics()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
234
    {
235
        $forumWithPosts = $this->objFromFixture("Forum", "general");
236
        
237
        $this->assertEquals($forumWithPosts->getTopics()->Count(), '4');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
238
        
239
        $forumWithoutPosts = $this->objFromFixture("Forum", "forum1cat2");
240
        $result = $forumWithoutPosts->getTopics();
241
        $this->assertEquals(0, $result->count());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
242
    }
243
    
244
    public function testGetLatestPost()
245
    {
246
        $forumWithPosts = $this->objFromFixture("Forum", "general");
247
248
        $this->assertEquals($forumWithPosts->getLatestPost()->Content, 'This is the last post to a long thread');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
249
    
250
        $forumWithoutPosts = $this->objFromFixture("Forum", "forum1cat2");
251
252
        $this->assertNull($forumWithoutPosts->getLatestPost());
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
253
    }
254
    
255 View Code Duplication
    public function testGetNumTopics()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
256
    {
257
        $forumWithPosts = $this->objFromFixture("Forum", "general");
258
        
259
        $this->assertEquals($forumWithPosts->getNumTopics(), 6);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
260
        
261
        $forumWithoutPosts = $this->objFromFixture("Forum", "forum1cat2");
262
263
        $this->assertEquals($forumWithoutPosts->getNumTopics(), 0);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
264
    }
265
    
266 View Code Duplication
    public function testGetTotalAuthors()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
267
    {
268
        $forumWithPosts = $this->objFromFixture("Forum", "general");
269
        
270
        $this->assertEquals($forumWithPosts->getNumAuthors(), 4);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
271
        
272
        $forumWithoutPosts = $this->objFromFixture("Forum", "forum1cat2");
273
274
        $this->assertEquals($forumWithoutPosts->getNumAuthors(), 0);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
275
    }
276
277
    /**
278
     * Note: See {@link testCanModerate()} for detailed permission tests.
279
     */
280
    public function testMarkAsSpamLink()
281
    {
282
        $spampost = $this->objFromFixture('Post', 'SpamSecondPost');
283
        $this->assertFalse($spampost->isFirstPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
284
        $forum = $spampost->Forum();
285
        $author = $spampost->Author();
286
        $moderator = $this->objFromFixture('Member', 'moderator'); // moderator for "general" forum
287
288
        // without a logged-in moderator
289
        $this->assertFalse($spampost->MarkAsSpamLink(), 'Link not present by default');
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
290
291
        $c = new Forum_Controller($forum);
292
        $response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/'. $spampost->ID), DataModel::inst());
293
        $this->assertEquals(403, $response->getStatusCode());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
294
295
        // with logged-in moderator
296
        $moderator->logIn();
297
        $this->assertNotEquals(false, $spampost->MarkAsSpamLink(), 'Link present for moderators on this forum');
0 ignored issues
show
Bug introduced by
The method assertNotEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
298
299
        $this->assertNull($author->SuspendedUntil);
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
300
301
        $c = new Forum_Controller($forum);
302
        $response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/'. $spampost->ID), DataModel::inst());
303
        $this->assertFalse($response->isError());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
304
305
        // removes the post
306
        $this->assertNull(Post::get()->byID($spampost->ID));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
307
        
308
        // suspends the member
309
        $author = Member::get()->byID($author->ID);
310
        $this->assertNotNull($author->SuspendedUntil);
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
311
        
312
        // does not effect the thread
313
        $thread = ForumThread::get()->byID($spampost->Thread()->ID);
314
        $this->assertEquals('1', $thread->getNumPosts());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
315
        
316
        // mark the first post in that now as spam
317
        $spamfirst = $this->objFromFixture('Post', 'SpamFirstPost');
318
319
        $response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/'. $spamfirst->ID), DataModel::inst());
0 ignored issues
show
Unused Code introduced by
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
320
321
        // removes the thread
322
        $this->assertNull(ForumThread::get()->byID($spamfirst->Thread()->ID));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
323
    }
324
325
    public function testBanLink()
326
    {
327
        $spampost = $this->objFromFixture('Post', 'SpamSecondPost');
328
        $forum = $spampost->Forum();
329
        $author = $spampost->Author();
330
        $moderator = $this->objFromFixture('Member', 'moderator'); // moderator for "general" forum
331
332
        // without a logged-in moderator
333
        $this->assertFalse($spampost->BanLink(), 'Link not present by default');
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
334
335
        $c = new Forum_Controller($forum);
336
        $response = $c->handleRequest(new SS_HTTPRequest('GET', 'ban/'. $spampost->AuthorID), DataModel::inst());
337
        $this->assertEquals(403, $response->getStatusCode());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
338
339
        // with logged-in moderator
340
        $moderator->logIn();
341
        $this->assertNotEquals(false, $spampost->BanLink(), 'Link present for moderators on this forum');
0 ignored issues
show
Bug introduced by
The method assertNotEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
342
343
        $c = new Forum_Controller($forum);
344
        $response = $c->handleRequest(new SS_HTTPRequest('GET', 'ban/'. $spampost->AuthorID), DataModel::inst());
345
        $this->assertFalse($response->isError());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
346
347
        // user is banned
348
        $author = Member::get()->byId($author->ID);
349
        $this->assertTrue($author->IsBanned());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
350
    }
351
352
    public function testGhostLink()
353
    {
354
        $spampost = $this->objFromFixture('Post', 'SpamSecondPost');
355
        $forum = $spampost->Forum();
356
        $author = $spampost->Author();
357
        $moderator = $this->objFromFixture('Member', 'moderator'); // moderator for "general" forum
358
359
        // without a logged-in moderator
360
        $this->assertFalse($spampost->GhostLink(), 'Link not present by default');
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
361
362
        $c = new Forum_Controller($forum);
363
        $response = $c->handleRequest(new SS_HTTPRequest('GET', 'ghost/'. $spampost->AuthorID), DataModel::inst());
364
        $this->assertEquals(403, $response->getStatusCode());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
365
366
        // with logged-in moderator
367
        $moderator->logIn();
368
        $this->assertNotEquals(false, $spampost->GhostLink(), 'Link present for moderators on this forum');
0 ignored issues
show
Bug introduced by
The method assertNotEquals() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
369
370
        $c = new Forum_Controller($forum);
371
        $response = $c->handleRequest(new SS_HTTPRequest('GET', 'ghost/'. $spampost->AuthorID), DataModel::inst());
372
        $this->assertFalse($response->isError());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
373
374
        // post isn't available anymore in normal queries. {@link ForumSpamPostExtension}
375
        $post = Post::get()->byId($spampost->ID);
376
        $this->assertNull($post);
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
377
378
        // user is banned
379
        $author = Member::get()->byId($author->ID);
380
        $this->assertTrue($author->IsGhost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ForumTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
381
    }
382
383
    public function testNotifyModerators()
384
    {
385
        SecurityToken::disable();
386
        $notifyModerators = Forum::$notify_moderators;
387
        Forum::$notify_moderators = true;
388
389
        $forum = $this->objFromFixture('Forum', 'general');
390
        $controller = new Forum_Controller($forum);
0 ignored issues
show
Unused Code introduced by
$controller is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
391
        $user = $this->objFromFixture('Member', 'test1');
392
        $this->session()->inst_set('loggedInAs', $user->ID);
393
394
        // New thread
395
        $this->post(
396
            $forum->RelativeLink('PostMessageForm'),
397
            array(
398
                'Title' => 'New thread',
399
                'Content' => 'Meticulously crafted content',
400
                'action_doPostMessageForm' => 1
401
            )
402
        );
403
404
        $adminEmail = Config::inst()->get('Email', 'admin_email');
405
406
        $this->assertEmailSent('[email protected]', $adminEmail, "New thread \"New thread\" in forum [General Discussion]");
407
        $this->clearEmails();
408
409
        // New response
410
        $thread = DataObject::get_one('ForumThread', "\"ForumThread\".\"Title\"='New thread'");
411
        $this->post(
412
            $forum->RelativeLink('PostMessageForm'),
413
            array(
414
                'Title' => 'Re: New thread',
415
                'Content' => 'Rough response',
416
                'ThreadID' => $thread->ID,
417
                'action_doPostMessageForm' => 1
418
            )
419
        );
420
        $this->assertEmailSent('[email protected]', $adminEmail, "New post \"Re: New thread\" in forum [General Discussion]");
421
        $this->clearEmails();
422
423
        // Edit
424
        $post = $thread->Posts()->Last();
425
        $this->post(
426
            $forum->RelativeLink('PostMessageForm'),
427
            array(
428
                'Title' => 'Re: New thread',
429
                'Content' => 'Pleasant response',
430
                'ThreadID' => $thread->ID,
431
                'ID' => $post->ID,
432
                'action_doPostMessageForm' => 1
433
            )
434
        );
435
        $this->assertEmailSent('[email protected]', $adminEmail, "New post \"Re: New thread\" in forum [General Discussion]");
436
        $this->clearEmails();
437
438
        Forum::$notify_moderators = $notifyModerators;
439
    }
440
}
441