Completed
Push — 2.2 ( 8a877d )
by Damian
09:45 queued 06:58
created

BlogTest::testRoles()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 119
Code Lines 74

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 119
rs 8.2857
cc 1
eloc 74
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * @mixin PHPUnit_Framework_TestCase
5
 */
6
class BlogTest extends SapphireTest {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

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

namespace YourVendor;

class YourClass { }

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

Loading history...
7
	/**
8
	 * @var string
9
	 */
10
	static $fixture_file = 'blog.yml';
0 ignored issues
show
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...
11
12
	/**
13
	 * {@inheritdoc}
14
	 */
15
	public function setUp() {
16
		parent::setUp();
17
18
		Config::nest();
19
		SS_Datetime::set_mock_now('2013-10-10 20:00:00');
20
21
		/**
22
		 * @var Blog $blog
23
		 */
24
		$blog = $this->objFromFixture('Blog', 'FirstBlog');
25
26
		$blog->publish('Stage', 'Live');
27
	}
28
29
	/**
30
	 * {@inheritdoc}
31
	 */
32
	public function tearDown() {
33
		SS_Datetime::clear_mock_now();
34
		Config::unnest();
35
36
		parent::tearDown();
37
	}
38
39
	public function testGetExcludedSiteTreeClassNames() {
40
		$member = Member::currentUser();
41
42
		if($member) {
43
			$member->logout();
44
		}
45
46
		/**
47
		 * @var Blog $blog
48
		 */
49
		$blog = $this->objFromFixture('Blog', 'FirstBlog');
50
51
		Config::inst()->update('BlogPost', 'show_in_sitetree', true);
52
		$classes = $blog->getExcludedSiteTreeClassNames();
53
54
		$this->assertNotContains('BlogPost', $classes, 'BlogPost class should be hidden.');
55
56
		Config::inst()->update('BlogPost', 'show_in_sitetree', false);
57
		$classes = $blog->getExcludedSiteTreeClassNames();
58
59
		$this->assertContains('BlogPost', $classes, 'BlogPost class should be hidden.');
60
	}
61
62
	public function testGetArchivedBlogPosts() {
63
		$member = Member::currentUser();
64
65
		if($member) {
66
			$member->logout();
67
		}
68
69
		/**
70
		 * @var Blog $blog
71
		 */
72
		$blog = $this->objFromFixture('Blog', 'FirstBlog');
73
74
		$archive = $blog->getArchivedBlogPosts(2013);
75
76
		$this->assertEquals(2, $archive->count(), 'Incorrect Yearly Archive count for 2013');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
77
		$this->assertEquals('First Post', $archive->first()->Title, 'Incorrect First Blog post');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
78
		$this->assertEquals('Second Post', $archive->last()->Title, 'Incorrect Last Blog post');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
79
80
		$archive = $blog->getArchivedBlogPosts(2013, 10);
81
82
		$this->assertEquals(1, $archive->count(), 'Incorrect monthly archive count.');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$archive = $blog->getArchivedBlogPosts(2013, 10, 01);
85
86
		$this->assertEquals(1, $archive->count(), 'Incorrect daily archive count.');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
87
	}
88
89
	public function testArchiveLinks() {
90
		/**
91
		 * @var Blog $blog
92
		 */
93
		$blog = $this->objFromFixture('Blog', 'FirstBlog');
94
95
		$link = Controller::join_links($blog->Link('archive'), '2013', '10', '01');
96
97
		$this->assertEquals(200, $this->getStatusOf($link), 'HTTP Status should be 200');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
98
99
		$link = Controller::join_links($blog->Link('archive'), '2013', '10');
100
101
		$this->assertEquals(200, $this->getStatusOf($link), 'HTTP Status should be 200');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
103
		$link = Controller::join_links($blog->Link('archive'), '2013');
104
105
		$this->assertEquals(200, $this->getStatusOf($link), 'HTTP Status should be 200');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
106
107
		$link = Controller::join_links($blog->Link('archive'), '2011', '10', '01');
108
109
		$this->assertEquals(200, $this->getStatusOf($link), 'HTTP Status should be 200');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
110
111
		$link = Controller::join_links($blog->Link('archive'));
112
		$this->assertEquals(200, $this->getStatusOf($link), 'HTTP Status should be 200');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
113
114
		$link = Controller::join_links($blog->Link('archive'), 'invalid-year');
115
116
		$this->assertEquals(404, $this->getStatusOf($link), 'HTTP Status should be 404');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
118
		$link = Controller::join_links($blog->Link('archive'), '2013', '99');
119
120
		$this->assertEquals(404, $this->getStatusOf($link), 'HTTP Status should be 404');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
121
122
		$link = Controller::join_links($blog->Link('archive'), '2013', '10', '99');
123
124
		$this->assertEquals(404, $this->getStatusOf($link), 'HTTP Status should be 404');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
125
126
	}
127
128
	/*
129
	 * Test archive year
130
	 */
131
	public function testArchiveYear(){
132
		$blog = $this->objFromFixture('Blog', 'FirstBlog');
133
		$controller = new Blog_Controller($blog);
134
		$this->requestURL($controller, 'first-post/archive/');
135
		$this->assertEquals(2013, $controller->getArchiveYear(), 'getArchiveYear should return 2013');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
136
	}
137
138
	/**
139
	 * @param string $link
140
	 *
141
	 * @return int
142
	 */
143
	protected function getStatusOf($link) {
144
		return Director::test($link)->getStatusCode();
145
	}
146
147
	public function testRoles() {
148
		/**
149
		 * @var Blog $firstBlog
150
		 */
151
		$firstBlog = $this->objFromFixture('Blog', 'FirstBlog');
152
153
		/**
154
		 * @var Blog $fourthBlog
155
		 */
156
		$fourthBlog = $this->objFromFixture('Blog', 'FourthBlog');
157
158
		/**
159
		 * @var BlogPost $postA
160
		 */
161
		$postA = $this->objFromFixture('BlogPost', 'PostA');
162
163
		/**
164
		 * @var BlogPost $postB
165
		 */
166
		$postB = $this->objFromFixture('BlogPost', 'PostB');
167
168
		/**
169
		 * @var BlogPost $postC
170
		 */
171
		$postC = $this->objFromFixture('BlogPost', 'PostC');
172
173
		/**
174
		 * @var Member $editor
175
		 */
176
		$editor = $this->objFromFixture('Member', 'BlogEditor');
177
178
		/**
179
		 * @var Member $writer
180
		 */
181
		$writer = $this->objFromFixture('Member', 'Writer');
182
183
		/**
184
		 * @var Member $contributor
185
		 */
186
		$contributor = $this->objFromFixture('Member', 'Contributor');
187
188
		/**
189
		 * @var Member $visitor
190
		 */
191
		$visitor = $this->objFromFixture('Member', 'Visitor');
192
193
		$this->assertEquals('Editor', $fourthBlog->RoleOf($editor));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
194
		$this->assertEquals('Contributor', $fourthBlog->RoleOf($contributor));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertEquals('Writer', $fourthBlog->RoleOf($writer));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
196
		$this->assertEmpty($fourthBlog->RoleOf($visitor));
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertEquals('Author', $postA->RoleOf($writer));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
198
		$this->assertEquals('Author', $postA->RoleOf($contributor));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
199
		$this->assertEquals('Editor', $postA->RoleOf($editor));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
200
		$this->assertEmpty($postA->RoleOf($visitor));
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<BlogTest>.

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

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

Loading history...
201
202
		// Test RoleOf with string values given
203
		$this->assertEquals('Editor', $fourthBlog->RoleOf((string)(int)$editor->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertEquals('Contributor', $fourthBlog->RoleOf((string)(int)$contributor->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
205
		$this->assertEquals('Writer', $fourthBlog->RoleOf((string)(int)$writer->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
206
		$this->assertEmpty($fourthBlog->RoleOf((string)(int)$visitor->ID));
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<BlogTest>.

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

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

Loading history...
207
		$this->assertEquals('Author', $postA->RoleOf((string)(int)$writer->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
208
		$this->assertEquals('Author', $postA->RoleOf((string)(int)$contributor->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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('Editor', $postA->RoleOf((string)(int)$editor->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertEmpty($postA->RoleOf((string)(int)$visitor->ID));
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<BlogTest>.

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

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

Loading history...
211
212
		// Test RoleOf with int values given
213
		$this->assertEquals('Editor', $fourthBlog->RoleOf((int)$editor->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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('Contributor', $fourthBlog->RoleOf((int)$contributor->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertEquals('Writer', $fourthBlog->RoleOf((int)$writer->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
216
		$this->assertEmpty($fourthBlog->RoleOf((int)$visitor->ID));
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertEquals('Author', $postA->RoleOf((int)$writer->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
218
		$this->assertEquals('Author', $postA->RoleOf((int)$contributor->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
219
		$this->assertEquals('Editor', $postA->RoleOf((int)$editor->ID));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
220
		$this->assertEmpty($postA->RoleOf((int)$visitor->ID));
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertTrue($fourthBlog->canEdit($editor));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
223
		$this->assertFalse($firstBlog->canEdit($editor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
224
		$this->assertTrue($fourthBlog->canAddChildren($editor));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
225
		$this->assertFalse($firstBlog->canAddChildren($editor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
226
		$this->assertTrue($postA->canEdit($editor));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertTrue($postB->canEdit($editor));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
228
		$this->assertTrue($postC->canEdit($editor));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
229
		$this->assertTrue($postA->canPublish($editor));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
230
		$this->assertTrue($postB->canPublish($editor));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
231
		$this->assertTrue($postC->canPublish($editor));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
232
233
		$this->assertFalse($fourthBlog->canEdit($writer));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
234
		$this->assertFalse($firstBlog->canEdit($writer));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
235
		$this->assertTrue($fourthBlog->canAddChildren($writer));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
236
		$this->assertFalse($firstBlog->canAddChildren($writer));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertTrue($postA->canEdit($writer));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
238
		$this->assertFalse($postB->canEdit($writer));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
239
		$this->assertTrue($postC->canEdit($writer));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
240
		$this->assertTrue($postA->canPublish($writer));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
241
		$this->assertFalse($postB->canPublish($writer));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
242
		$this->assertTrue($postC->canPublish($writer));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertFalse($fourthBlog->canEdit($contributor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
245
		$this->assertFalse($firstBlog->canEdit($contributor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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->assertTrue($fourthBlog->canAddChildren($contributor));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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($firstBlog->canAddChildren($contributor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertTrue($postA->canEdit($contributor));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
249
		$this->assertFalse($postB->canEdit($contributor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
250
		$this->assertTrue($postC->canEdit($contributor));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BlogTest>.

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

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

Loading history...
251
		$this->assertFalse($postA->canPublish($contributor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
252
		$this->assertFalse($postB->canPublish($contributor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertFalse($postC->canPublish($contributor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
254
255
		$this->assertFalse($fourthBlog->canEdit($visitor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
256
		$this->assertFalse($firstBlog->canEdit($visitor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
		$this->assertFalse($fourthBlog->canAddChildren($visitor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
258
		$this->assertFalse($firstBlog->canAddChildren($visitor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
259
		$this->assertFalse($postA->canEdit($visitor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
260
		$this->assertFalse($postB->canEdit($visitor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
261
		$this->assertFalse($postC->canEdit($visitor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
262
		$this->assertFalse($postA->canPublish($visitor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

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

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

Loading history...
263
		$this->assertFalse($postB->canPublish($visitor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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($postC->canPublish($visitor));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BlogTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself 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
	public function testFilteredCategories() {
268
		$blog = $this->objFromFixture('Blog', 'FirstBlog');
269
		$controller = new Blog_Controller($blog);
270
		
271
		// Root url
272
		$this->requestURL($controller, 'first-post');
273
		$this->assertIDsEquals(
274
			$blog->AllChildren()->column('ID'),
275
			$controller->PaginatedList()->column('ID')
276
		);
277
278
279
		// RSS
280
		$this->requestURL($controller, 'first-post/rss');
281
		$this->assertIDsEquals(
282
			$blog->AllChildren()->column('ID'),
283
			$controller->PaginatedList()->column('ID')
284
		);
285
286
		// Posts
287
		$firstPostID = $this->idFromFixture('BlogPost', 'FirstBlogPost');
288
		$secondPostID = $this->idFromFixture('BlogPost', 'SecondBlogPost');
289
		$firstFuturePostID = $this->idFromFixture('BlogPost', 'FirstFutureBlogPost');
290
		$secondFuturePostID = $this->idFromFixture('BlogPost', 'SecondFutureBlogPost');
291
292
		// Request first tag
293
		$this->requestURL($controller, 'first-post/tag/first-tag');
294
		$this->assertIDsEquals(
295
			array($firstPostID, $firstFuturePostID, $secondFuturePostID),
296
			$controller->PaginatedList()
297
		);
298
299
		// Request 2013 posts
300
		$this->requestURL($controller, 'first-post/archive/2013');
301
		$this->assertIDsEquals(
302
			array($firstPostID, $secondPostID, $secondFuturePostID),
303
			$controller->PaginatedList()
304
		);
305
	}
306
307
	/**
308
	 * Mock a request against a given controller
309
	 *
310
	 * @param ContentController $controller
311
	 * @param string $url
312
	 */
313
	protected function requestURL(ContentController $controller, $url) {
314
		$request = new SS_HTTPRequest('get', $url);
315
		$request->match('$URLSegment//$Action/$ID/$OtherID');
316
		$request->shift();
317
		$controller->init();
318
		$controller->handleRequest($request, new DataModel());
319
	}
320
321
	/**
322
	 * Assert these id lists match
323
	 *
324
	 * @param array|SS_List $left
325
	 * @param array|SS_List $right
326
	 */
327
	protected function assertIDsEquals($left, $right) {
328
		if($left instanceof SS_List) $left = $left->column('ID');
329
		if($right instanceof SS_List) $right = $right->column('ID');
330
		asort($left);
331
		asort($right);
332
		$this->assertEquals(array_values($left), array_values($right));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogTest>.

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

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

Loading history...
333
	}
334
}
335