Completed
Push — master ( 691103...b765dd )
by Daniel
11:12 queued 08:42
created

ForumTest   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 413
Duplicated Lines 39.95 %

Coupling/Cohesion

Components 1
Dependencies 14
Metric Value
wmc 19
lcom 1
cbo 14
dl 165
loc 413
rs 10

16 Methods

Rating   Name   Duplication   Size   Complexity  
B testCanView() 46 46 2
B testCanPost() 46 46 2
A testSuspended() 0 22 1
B testCanModerate() 46 46 2
A testCanAttach() 0 7 1
A testgetForbiddenWords() 0 5 1
A testfilterLanguage() 0 9 1
A testGetStickyTopics() 0 19 1
A testTopics() 9 9 1
A testGetLatestPost() 0 9 1
A testGetNumTopics() 9 9 1
A testGetTotalAuthors() 9 9 1
B testMarkAsSpamLink() 0 43 1
B testBanLink() 0 25 1
B testGhostLink() 0 29 1
A testNotifyModerators() 0 56 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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...
Coding Style introduced by
As per PSR2, the opening brace for this class should be on a new line.
Loading history...
7
	
8
	static $fixture_file = "forum/tests/ForumTest.yml";
0 ignored issues
show
Coding Style introduced by
We recommend specifying an explicit visibility for the field $fixture_file.
Loading history...
Coding Style introduced by
The visibility should be declared for property $fixture_file.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
9
	static $use_draft_site = true;
0 ignored issues
show
Coding Style introduced by
We recommend specifying an explicit visibility for the field $use_draft_site.
Loading history...
Coding Style introduced by
The visibility should be declared for property $use_draft_site.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
10
	
11 View Code Duplication
	function testCanView() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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
		// test viewing not logged in
13
		if($member = Member::currentUser()) $member->logOut();
14
		
15
		$public = $this->objFromFixture('Forum', 'general');
16
		$private = $this->objFromFixture('Forum', 'loggedInOnly');
17
		$limited = $this->objFromFixture('Forum', 'limitedToGroup');
18
		$noposting = $this->objFromFixture('Forum', 'noPostingForum');
19
		$inherited = $this->objFromFixture('Forum', 'inheritedForum');
20
		
21
		$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...
22
		$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...
23
		$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...
24
		$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...
25
		$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...
26
		
27
		// try logging in a member
28
		$member = $this->objFromFixture('Member', 'test1');
29
		$member->logIn();
30
		
31
		$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...
32
		$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...
33
		$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...
34
		$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...
35
		$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...
36
		
37
		// login as a person with access to restricted forum
38
		$member = $this->objFromFixture('Member', 'test2');
39
		$member->logIn();
40
		
41
		$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...
42
		$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...
43
		$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...
44
		$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...
45
		$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...
46
47
		// Moderator should be able to view his own forums
48
		$member = $this->objFromFixture('Member', 'moderator');
49
		$member->logIn();
50
51
		$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...
52
		$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...
53
		$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...
54
		$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...
55
		$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...
56
	}
57
58 View Code Duplication
	function testCanPost() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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...
59
		// test viewing not logged in
60
		if($member = Member::currentUser()) $member->logOut();
61
		
62
		$public = $this->objFromFixture('Forum', 'general');
63
		$private = $this->objFromFixture('Forum', 'loggedInOnly');
64
		$limited = $this->objFromFixture('Forum', 'limitedToGroup');
65
		$noposting = $this->objFromFixture('Forum', 'noPostingForum');
66
		$inherited = $this->objFromFixture('Forum', 'inheritedForum');
67
		
68
		$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...
69
		$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...
70
		$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...
71
		$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...
72
		$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...
73
		
74
		// try logging in a member
75
		$member = $this->objFromFixture('Member', 'test1');
76
		$member->logIn();
77
		
78
		$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...
79
		$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...
80
		$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...
81
		$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...
82
		$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...
83
		
84
		// login as a person with access to restricted forum
85
		$member = $this->objFromFixture('Member', 'test2');
86
		$member->logIn();
87
		
88
		$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...
89
		$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...
90
		$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...
91
		$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...
92
		$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...
93
94
		// Moderator should be able to view his own forums
95
		$member = $this->objFromFixture('Member', 'moderator');
96
		$member->logIn();
97
98
		$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...
99
		$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...
100
		$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...
101
		$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...
102
		$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...
103
	}
104
	
105
	function testSuspended() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
106
		$private = $this->objFromFixture('Forum', 'loggedInOnly');
107
		$limited = $this->objFromFixture('Forum', 'limitedToGroup');
108
		$inheritedForum_loggedInOnly = $this->objFromFixture('Forum', 'inheritedForum_loggedInOnly');
109
		SS_Datetime::set_mock_now('2011-10-10 12:00:00');	
110
			
111
		// try logging in a member suspendedexpired
112
		$suspendedexpired = $this->objFromFixture('Member', 'suspendedexpired');
113
		$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...
114
		$suspendedexpired->logIn();
115
		$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...
116
		$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...
117
		$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...
118
		
119
		// try logging in a member suspended
120
		$suspended = $this->objFromFixture('Member', 'suspended');
121
		$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...
122
		$suspended->logIn();
123
		$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...
124
		$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...
125
		$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...
126
	}
127
128 View Code Duplication
	function testCanModerate() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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...
129
		// test viewing not logged in
130
		if($member = Member::currentUser()) $member->logOut();
131
		
132
		$public = $this->objFromFixture('Forum', 'general');
133
		$private = $this->objFromFixture('Forum', 'loggedInOnly');
134
		$limited = $this->objFromFixture('Forum', 'limitedToGroup');
135
		$noposting = $this->objFromFixture('Forum', 'noPostingForum');
136
		$inherited = $this->objFromFixture('Forum', 'inheritedForum');
137
		
138
		$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...
139
		$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...
140
		$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...
141
		$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...
142
		$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...
143
		
144
		// try logging in a member
145
		$member = $this->objFromFixture('Member', 'test1');
146
		$member->logIn();
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
		// login as a person with access to restricted forum
155
		$member = $this->objFromFixture('Member', 'test2');
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
		// Moderator should be able to view his own forums
165
		$member = $this->objFromFixture('Member', 'moderator');
166
		$member->logIn();
167
168
		$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...
169
		$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...
170
		$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...
171
		$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...
172
		$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...
173
	}
174
175
	function testCanAttach() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
176
		$canAttach = $this->objFromFixture('Forum', 'general');
177
		$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...
178
		
179
		$noAttach = $this->objFromFixture('Forum', 'forum1cat2');
180
		$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...
181
	}
182
	
183
	function testgetForbiddenWords(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
184
		$forum = $this->objFromFixture("Forum", "general");
185
		$f_controller = new Forum_Controller($forum);
186
		$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...
187
	}
188
	
189
	function testfilterLanguage(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
190
		$forum =  $this->objFromFixture("Forum", "general");
191
		$f_controller = new Forum_Controller($forum);
192
		$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...
193
		
194
		$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...
195
		
196
		$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...
197
	}
198
	
199
	function testGetStickyTopics() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
200
		$forumWithSticky = $this->objFromFixture("Forum", "general");
201
		$stickies = $forumWithSticky->getStickyTopics();
202
		$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...
203
204
		// TODO: Sorts by Created, which is all equal on all Posts in test, and can't be overridden, so can't rely on order
205
		//$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...
206
207
		$stickies = $forumWithSticky->getStickyTopics($include_global = false);
208
		$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...
209
		$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...
210
		
211
		$forumWithGlobalOnly = $this->objFromFixture("Forum", "forum1cat2");
212
		$stickies = $forumWithGlobalOnly->getStickyTopics();
213
		$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...
214
		$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...
215
		$stickies = $forumWithGlobalOnly->getStickyTopics($include_global = false);
216
		$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...
217
	}
218
	
219 View Code Duplication
	function testTopics() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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...
220
		$forumWithPosts = $this->objFromFixture("Forum", "general");
221
		
222
		$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...
223
		
224
		$forumWithoutPosts = $this->objFromFixture("Forum", "forum1cat2");
225
		$result = $forumWithoutPosts->getTopics();
226
		$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...
227
	}
228
	
229
	function testGetLatestPost() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
230
		$forumWithPosts = $this->objFromFixture("Forum", "general");
231
232
		$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...
233
	
234
		$forumWithoutPosts = $this->objFromFixture("Forum", "forum1cat2");
235
236
		$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...
237
	}
238
	
239 View Code Duplication
	function testGetNumTopics() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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...
240
		$forumWithPosts = $this->objFromFixture("Forum", "general");
241
		
242
		$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...
243
		
244
		$forumWithoutPosts = $this->objFromFixture("Forum", "forum1cat2");
245
246
		$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...
247
	}
248
	
249 View Code Duplication
	function testGetTotalAuthors() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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...
250
		$forumWithPosts = $this->objFromFixture("Forum", "general");
251
		
252
		$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...
253
		
254
		$forumWithoutPosts = $this->objFromFixture("Forum", "forum1cat2");
255
256
		$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...
257
	}
258
259
	/**
260
	 * Note: See {@link testCanModerate()} for detailed permission tests.
261
	 */
262
	public function testMarkAsSpamLink() {
263
		$spampost = $this->objFromFixture('Post', 'SpamSecondPost');
264
		$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...
265
		$forum = $spampost->Forum();
266
		$author = $spampost->Author();
267
		$moderator = $this->objFromFixture('Member', 'moderator'); // moderator for "general" forum
268
		
269
		// without a logged-in moderator
270
		$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...
271
272
		$c = new Forum_Controller($forum);
273
		$response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/'. $spampost->ID), DataModel::inst());
274
		$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...
275
276
		// with logged-in moderator
277
		$moderator->logIn();
278
		$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...
279
280
		$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...
281
282
		$c = new Forum_Controller($forum);
283
		$response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/'. $spampost->ID), DataModel::inst());
284
		$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...
285
286
		// removes the post
287
		$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...
288
		
289
		// suspends the member
290
		$author = Member::get()->byID($author->ID);
291
		$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...
292
		
293
		// does not effect the thread
294
		$thread = ForumThread::get()->byID($spampost->Thread()->ID);
295
		$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...
296
		
297
		// mark the first post in that now as spam
298
		$spamfirst = $this->objFromFixture('Post', 'SpamFirstPost');
299
300
		$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...
301
302
		// removes the thread
303
		$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...
304
	}
305
306
	function testBanLink() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
307
		$spampost = $this->objFromFixture('Post', 'SpamSecondPost');
308
		$forum = $spampost->Forum();
309
		$author = $spampost->Author();
310
		$moderator = $this->objFromFixture('Member', 'moderator'); // moderator for "general" forum
311
312
		// without a logged-in moderator
313
		$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...
314
315
		$c = new Forum_Controller($forum);
316
		$response = $c->handleRequest(new SS_HTTPRequest('GET', 'ban/'. $spampost->AuthorID), DataModel::inst());
317
		$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...
318
319
		// with logged-in moderator
320
		$moderator->logIn();
321
		$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...
322
323
		$c = new Forum_Controller($forum);
324
		$response = $c->handleRequest(new SS_HTTPRequest('GET', 'ban/'. $spampost->AuthorID), DataModel::inst());
325
		$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...
326
327
		// user is banned
328
		$author = Member::get()->byId($author->ID);
329
		$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...
330
	}
331
332
	function testGhostLink() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
333
		$spampost = $this->objFromFixture('Post', 'SpamSecondPost');
334
		$forum = $spampost->Forum();
335
		$author = $spampost->Author();
336
		$moderator = $this->objFromFixture('Member', 'moderator'); // moderator for "general" forum
337
338
		// without a logged-in moderator
339
		$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...
340
341
		$c = new Forum_Controller($forum);
342
		$response = $c->handleRequest(new SS_HTTPRequest('GET', 'ghost/'. $spampost->AuthorID), DataModel::inst());
343
		$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...
344
345
		// with logged-in moderator
346
		$moderator->logIn();
347
		$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...
348
349
		$c = new Forum_Controller($forum);
350
		$response = $c->handleRequest(new SS_HTTPRequest('GET', 'ghost/'. $spampost->AuthorID), DataModel::inst());
351
		$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...
352
353
		// post isn't available anymore in normal queries. {@link ForumSpamPostExtension}
354
		$post = Post::get()->byId($spampost->ID);
355
		$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...
356
357
		// user is banned
358
		$author = Member::get()->byId($author->ID);
359
		$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...
360
	}
361
362
	function testNotifyModerators() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
363
		SecurityToken::disable();
364
		$notifyModerators = Forum::$notify_moderators;
0 ignored issues
show
Bug introduced by
The property notify_moderators cannot be accessed from this context as it is declared private in class Forum.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
365
		Forum::$notify_moderators = true;
0 ignored issues
show
Bug introduced by
The property notify_moderators cannot be accessed from this context as it is declared private in class Forum.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
366
367
		$forum = $this->objFromFixture('Forum', 'general');
368
		$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...
369
		$user = $this->objFromFixture('Member', 'test1');
370
		$this->session()->inst_set('loggedInAs', $user->ID);
371
372
		// New thread
373
		$this->post(
374
			$forum->RelativeLink('PostMessageForm'),
375
			array(
376
				'Title' => 'New thread',
377
				'Content' => 'Meticulously crafted content',
378
				'action_doPostMessageForm' => 1
379
			)
380
		);
381
382
		$adminEmail = Config::inst()->get('Email', 'admin_email');
383
384
		$this->assertEmailSent('[email protected]', $adminEmail, "New thread \"New thread\" in forum [General Discussion]");
385
		$this->clearEmails();
386
387
		// New response
388
		$thread = DataObject::get_one('ForumThread', "\"ForumThread\".\"Title\"='New thread'");
389
		$this->post(
390
			$forum->RelativeLink('PostMessageForm'),
391
			array(
392
				'Title' => 'Re: New thread',
393
				'Content' => 'Rough response',
394
				'ThreadID' => $thread->ID,
395
				'action_doPostMessageForm' => 1
396
			)
397
		);
398
		$this->assertEmailSent('[email protected]', $adminEmail, "New post \"Re: New thread\" in forum [General Discussion]");
399
		$this->clearEmails();
400
401
		// Edit
402
		$post = $thread->Posts()->Last();
403
		$this->post(
404
			$forum->RelativeLink('PostMessageForm'),
405
			array(
406
				'Title' => 'Re: New thread',
407
				'Content' => 'Pleasant response',
408
				'ThreadID' => $thread->ID,
409
				'ID' => $post->ID,
410
				'action_doPostMessageForm' => 1
411
			)
412
		);
413
		$this->assertEmailSent('[email protected]', $adminEmail, "New post \"Re: New thread\" in forum [General Discussion]");
414
		$this->clearEmails();
415
416
		Forum::$notify_moderators = $notifyModerators;
0 ignored issues
show
Bug introduced by
The property notify_moderators cannot be accessed from this context as it is declared private in class Forum.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
417
	}
418
}
419