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

PostTest::testBanAndGhostLink()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 27
rs 8.8571
cc 2
eloc 16
nc 2
nop 0
1
<?php
2
3
class PostTest 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...
4
	
5
	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...
6
7
	// fixes permission issues with these tests, we don't need to test versioning anyway.
8
	// without this, SiteTree::canView() would always return false even though CanViewType == Anyone.
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
	public function setUp(){
12
		parent::setUp();
13
14
		//track the default state of tokens
15
		$this->useToken = SecurityToken::is_enabled();
0 ignored issues
show
Bug introduced by
The property useToken does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16
17
	}
18
19
	public function tearDown(){
20
		parent::tearDown();
21
22
		//if the token is turned on reset it before the next test run
23
		if($this->useToken) {
24
			SecurityToken::enable();
25
		} else {
26
			SecurityToken::disable();
27
		}
28
	}
29
30
	function testPermissions() {
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...
31
		$member1 = $this->objFromFixture('Member', 'test1');
32
		$member2 = $this->objFromFixture('Member', 'test2');
33
		$moderator = $this->objFromFixture('Member', 'moderator');
34
		$admin = $this->objFromFixture('Member', 'admin');
35
		
36
		$postMember2 = $this->objFromFixture('Post', 'Post18');  
37
		
38
		// read only thread post
39
		$member1->logIn();
40
		$postReadonly = $this->objFromFixture('Post', 'ReadonlyThreadPost');
41
		$this->assertFalse($postReadonly->canEdit()); // Even though it's user's own
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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($postReadonly->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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->assertFalse($postReadonly->canCreate());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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->assertFalse($postReadonly->canDelete());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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
		
46
		// normal thread. They can post to these
47
		$member1->logIn();
48
		$this->assertFalse($postMember2->canEdit()); // Not user's post
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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
		$this->assertTrue($postMember2->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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...
50
		$this->assertTrue($postMember2->canCreate());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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...
51
		$this->assertFalse($postMember2->canDelete());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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
		
53
		// Check the user has full rights on his own post
54
		$member2->logIn();
55
		$this->assertTrue($postMember2->canEdit()); // User's post
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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($postMember2->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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($postMember2->canCreate());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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($postMember2->canDelete());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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
		// Moderator can delete posts, even if he doesn't own them
61
		$moderator->logIn();
62
		$this->assertFalse($postMember2->canEdit());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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...
63
		$this->assertTrue($postMember2->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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...
64
		$this->assertTrue($postMember2->canCreate());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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...
65
		$this->assertTrue($postMember2->canDelete());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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...
66
67
		// Admins should have full rights, even if they're not moderators or own the post
68
		$admin->logIn();
69
		$this->assertTrue($postMember2->canEdit());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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->assertTrue($postMember2->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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->assertTrue($postMember2->canCreate());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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->assertTrue($postMember2->canDelete());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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
	
75
	function testGetTitle() {
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...
76
		$post = $this->objFromFixture('Post', 'Post1');
77
		$reply = $this->objFromFixture('Post', 'Post2');
78
		
79
		$this->assertEquals($post->Title, "Test Thread");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PostTest>.

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->assertEquals($reply->Title, "Re: Test Thread");
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PostTest>.

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
		
82
		$first = $this->objFromFixture('Post', 'Post3');
83
		$this->assertEquals($first->Title, 'Another Test Thread');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PostTest>.

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...
84
	}
85
	
86
	function testIssFirstPost() {
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...
87
		$first = $this->objFromFixture('Post', 'Post1');
88
		$this->assertTrue($first->isFirstPost());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PostTest>.

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
		$notFirst = $this->objFromFixture('Post', 'Post2');
91
		$this->assertFalse($notFirst->isFirstPost());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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
	}
93
	
94
	function testReplyLink() {
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...
95
		$post = $this->objFromFixture('Post', 'Post1');
96
		$this->assertContains($post->Thread()->URLSegment .'/reply/'.$post->ThreadID , $post->ReplyLink());
97
	}
98
	
99
	function testShowLink() {
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...
100
		$post = $this->objFromFixture('Post', 'Post1');
101
		Forum::$posts_per_page = 8;
0 ignored issues
show
Bug introduced by
The property posts_per_page 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...
102
		
103
		// test for show link on first page
104
		$this->assertContains($post->Thread()->URLSegment .'/show/'.$post->ThreadID, $post->ShowLink());
105
		
106
		// test for link that should be last post on the first page
107
		$eighthPost = $this->objFromFixture('Post', 'Post9');
108
		$this->assertContains($eighthPost->Thread()->URLSegment .'/show/'.$eighthPost->ThreadID.'#post'.$eighthPost->ID , $eighthPost->ShowLink());
109
		
110
		// test for a show link on a subpage
111
		$lastPost = $this->objFromFixture('Post', 'Post10');
112
		$this->assertContains($lastPost->Thread()->URLSegment .'/show/'. $lastPost->ThreadID . '?start=8#post'.$lastPost->ID, $lastPost->ShowLink());
113
		
114
		// this is the last post on page 2
115
		$lastPost = $this->objFromFixture('Post', 'Post17');
116
		$this->assertContains($lastPost->Thread()->URLSegment .'/show/'. $lastPost->ThreadID . '?start=8#post'.$lastPost->ID, $lastPost->ShowLink());
117
			
118
		// test for a show link on the last subpage
119
		$lastPost = $this->objFromFixture('Post', 'Post18');
120
		$this->assertContains($lastPost->Thread()->URLSegment .'/show/'. $lastPost->ThreadID . '?start=16#post'.$lastPost->ID, $lastPost->ShowLink());
121
	}
122
	
123
	function testEditLink() {
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...
124
		$post = $this->objFromFixture('Post', 'Post1');
125
126
		// should be false since we're not logged in.
127
		if($member = Member::currentUser()) $member->logOut();
128
		
129
		$this->assertFalse($post->EditLink());		
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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...
130
		
131
		// logged in as the member. Should be able to edit it
132
		$member = $this->objFromFixture('Member', 'test1');
133
		$member->logIn();
134
		
135
		$this->assertContains($post->Thread()->URLSegment .'/editpost/'. $post->ID, $post->EditLink());
136
		
137
		// log in as another member who is not
138
		$member->logOut();
139
		
140
		$memberOther = $this->objFromFixture('Member', 'test2');
141
		$memberOther->logIn();
142
		
143
		$this->assertFalse($post->EditLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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...
144
	}
145
	
146 View Code Duplication
	function testDeleteLink() {
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...
147
		$post = $this->objFromFixture('Post', 'Post1');
148
149
		//enable token
150
		SecurityToken::enable();
151
152
		// should be false since we're not logged in.
153
		if($member = Member::currentUser()) $member->logOut();
154
		
155
		$this->assertFalse($post->EditLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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...
156
		$this->assertFalse($post->DeleteLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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...
157
		
158
		// logged in as the moderator. Should be able to delete the post.
159
		$member = $this->objFromFixture('Member', 'moderator');
160
		$member->logIn();
161
		
162
		$this->assertContains($post->Thread()->URLSegment .'/deletepost/'. $post->ID, $post->DeleteLink());
163
		
164
		// because this is the first post test for the class which is used in javascript
165
		$this->assertContains("class=\"deleteLink firstPost\"", $post->DeleteLink());
166
167
		$member->logOut();
168
		
169
		// log in as another member who is not in a position to delete this post
170
		$member = $this->objFromFixture('Member', 'test2');
171
		$member->logIn();
172
		
173
		$this->assertFalse($post->DeleteLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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...
174
		
175
		// log in as someone who can moderate this post (and therefore delete it)
176
		$member = $this->objFromFixture('Member', 'moderator');
177
		$member->logIn();
178
179
180
		//check for the existance of a CSRF token
181
		$this->assertContains("SecurityID=", $post->DeleteLink());
182
183
		// should be able to edit post since they're moderators
184
		$this->assertContains($post->Thread()->URLSegment .'/deletepost/'. $post->ID, $post->DeleteLink());
185
		
186
		// test that a 2nd post doesn't have the first post ID hook
187
		$memberOthersPost = $this->objFromFixture('Post', 'Post2');
188
		
189
		$this->assertFalse(strstr($memberOthersPost->DeleteLink(), "firstPost"));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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...
190
191
	}
192
193 View Code Duplication
	function testMarkAsSpamLink() {
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...
194
		$post = $this->objFromFixture('Post', 'Post1');
195
196
		//enable token
197
		SecurityToken::enable();
198
199
		// should be false since we're not logged in.
200
		if($member = Member::currentUser()) $member->logOut();
201
202
		$this->assertFalse($post->EditLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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
		$this->assertFalse($post->MarkAsSpamLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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...
204
205
		// logged in as the moderator. Should be able to mark the post as spam.
206
		$member = $this->objFromFixture('Member', 'moderator');
207
		$member->logIn();
208
209
		$this->assertContains($post->Thread()->URLSegment .'/markasspam/'. $post->ID, $post->MarkAsSpamLink());
210
211
		// because this is the first post test for the class which is used in javascript
212
		$this->assertContains("class=\"markAsSpamLink firstPost\"", $post->MarkAsSpamLink());
213
214
		$member->logOut();
215
216
		// log in as another member who is not in a position to mark post as spam this post
217
		$member = $this->objFromFixture('Member', 'test2');
218
		$member->logIn();
219
220
		$this->assertFalse($post->MarkAsSpamLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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...
221
222
		// log in as someone who can moderate this post (and therefore mark as spam)
223
		$member = $this->objFromFixture('Member', 'moderator');
224
		$member->logIn();
225
226
227
		//check for the existance of a CSRF token
228
		$this->assertContains("SecurityID=", $post->MarkAsSpamLink());
229
230
		// should be able to edit post since they're moderators
231
		$this->assertContains($post->Thread()->URLSegment .'/markasspam/'. $post->ID, $post->MarkAsSpamLink());
232
233
		// test that a 2nd post doesn't have the first post ID hook
234
		$memberOthersPost = $this->objFromFixture('Post', 'Post2');
235
236
		$this->assertFalse(strstr($memberOthersPost->MarkAsSpamLink(), "firstPost"));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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
	public function testBanAndGhostLink() {
240
		$post = $this->objFromFixture('Post', 'Post1');
241
242
		// should be false since we're not logged in.
243
		if($member = Member::currentUser()) $member->logOut();
244
245
		$this->assertFalse($post->EditLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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...
246
		$this->assertFalse($post->BanLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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
		$this->assertFalse($post->GhostLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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...
248
249
		// logged in as the moderator. Should be able to mark the post as spam.
250
		$member = $this->objFromFixture('Member', 'moderator');
251
		$member->logIn();
252
253
		$forum = $post->Thread()->Forum();
254
		$this->assertContains($forum->URLSegment . '/ban/' . $post->AuthorID, $post->BanLink());
255
		$this->assertContains($forum->URLSegment . '/ghost/' . $post->AuthorID, $post->GhostLink());
256
257
		$member->logOut();
258
259
		// log in as another member who is not in a position to mark post as spam this post
260
		$member = $this->objFromFixture('Member', 'test2');
261
		$member->logIn();
262
263
		$this->assertFalse($post->BanLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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
		$this->assertFalse($post->GhostLink());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<PostTest>.

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
	}
266
	
267
	function testGetUpdated() {
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...
268
		$post = new Post();
269
		$post->Content = "Original Content";
0 ignored issues
show
Documentation introduced by
The property Content does not exist on object<Post>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
270
		$post->write();
271
272
		$this->assertNull($post->Updated);
0 ignored issues
show
Documentation introduced by
The property Updated does not exist on object<Post>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The method assertNull() does not seem to exist on object<PostTest>.

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...
273
		sleep(2);
274
		$post->Content = "Some Content Now";
0 ignored issues
show
Documentation introduced by
The property Content does not exist on object<Post>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
275
		$post->write();
276
		
277
		$this->assertNotNull($post->Updated);
0 ignored issues
show
Documentation introduced by
The property Updated does not exist on object<Post>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The method assertNotNull() does not seem to exist on object<PostTest>.

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...
278
	}
279
	
280
	function testRSSContent() {
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...
281
		// @todo escaping tests. They are handled by bbcode parser tests?
282
	}
283
	
284
	function testRSSAuthor() {
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...
285
		// @todo 
286
	}
287
}
288