Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

FIX: Implement paginated list for RSS feed. Fixes #31.

Includes functional tests for the RSSFeed but currently commented out until that feature lands in the main framework.
  • Loading branch information...
commit 6d3597095ff1b39ac938076a9f9abab94168c198 1 parent bcd16e1
Will Rossiter authored July 31, 2012
3  _config.php
@@ -21,6 +21,9 @@
21 21
  *		'require_login' => true
22 22
  *	));
23 23
  * </code>
  24
+ *
  25
+ * To see all the configuration options read docs/en/Configuration.md or
  26
+ * consult the Commenting class.
24 27
  */
25 28
 
26 29
 Commenting::add('SiteTree');
4  _config/routes.yml
@@ -5,5 +5,5 @@ After: framework/routes#coreroutes
5 5
 Director:
6 6
   rules:
7 7
     # handle old 2.4 style urls
8  
-    'PageComments/$Action/$ID': 'CommentingController'
9  
-    'PageComments_Controller/$Action/$ID': 'CommentingController'
  8
+    'PageComments/$Action/$ID/$OtherID': 'CommentingController'
  9
+    'PageComments_Controller/$Action/$ID/$OtherID': 'CommentingController'
4  code/Commenting.php
@@ -114,8 +114,8 @@ public static function set_config_value($class, $key, $value = false) {
114 114
 	 * @throws Exception 
115 115
 	 * @return mixed
116 116
 	 */
117  
-	public static function get_config_value($class, $key) {
118  
-		if(isset(self::$enabled_classes[$class])) {
  117
+	public static function get_config_value($class = null, $key) {
  118
+		if(!$class || isset(self::$enabled_classes[$class])) {
119 119
 			// custom configuration
120 120
 			if(isset(self::$enabled_classes[$class][$key])) return self::$enabled_classes[$class][$key];
121 121
 			
65  code/controllers/CommentingController.php
@@ -15,7 +15,7 @@ class CommentingController extends Controller {
15 15
 		'CommentsForm',
16 16
 		'doPostComment'
17 17
 	);
18  
-	
  18
+
19 19
 	private $baseClass = "";
20 20
 	private $ownerRecord = "";
21 21
 	private $ownerController = "";
@@ -54,19 +54,30 @@ public function Link($action = "", $id = '', $other = '') {
54 54
 	}
55 55
 	
56 56
 	/**
57  
-	 * Return an RSS feed of comments for a given set of comments or all 
  57
+	 * Outputs the RSS feed of comments
  58
+	 *
  59
+	 * @return XML
  60
+	 */
  61
+	public function rss() {
  62
+		return $this->getFeed($this->request)->outputToBrowser();
  63
+	}
  64
+
  65
+	/**
  66
+	 * Return an RSSFeed of comments for a given set of comments or all 
58 67
 	 * comments on the website.
59 68
 	 *
60 69
 	 * To maintain backwards compatibility with 2.4 this supports mapping
61 70
 	 * of PageComment/rss?pageid= as well as the new RSS format for comments
62 71
 	 * of CommentingController/rss/{classname}/{id}
63 72
 	 *
64  
-	 * @return RSS
  73
+	 * @param SS_HTTPRequest
  74
+	 *
  75
+	 * @return RSSFeed
65 76
 	 */
66  
-	public function rss() {
  77
+	public function getFeed(SS_HTTPRequest $request) {
67 78
 		$link = $this->Link('rss');
68  
-		$class = $this->urlParams['ID'];
69  
-		$id = $this->urlParams['OtherID'];
  79
+		$class = $request->param('ID');
  80
+		$id = $request->param('OtherID');
70 81
 
71 82
 		if(isset($_GET['pageid'])) {
72 83
 			$id =  Convert::raw2sql($_GET['pageid']);
@@ -99,22 +110,22 @@ public function rss() {
99 110
 				return $this->httpError(404);
100 111
 			}
101 112
 		} else {
102  
-			$comments = Comment::get();
  113
+			$comments = Comment::get()->where("Moderated = 1 AND IsSpam = 0");
103 114
 		}
104 115
 
105 116
 		$title = _t('CommentingController.RSSTITLE', "Comments RSS Feed");
106 117
 
107  
-		$feed = new RSSFeed($comments, $link, $title, $link, 'Title', 'Comment', 'AuthorName');
108  
-		$feed->outputToBrowser();
  118
+		$comments = new PaginatedList($comments, $request);
  119
+		$comments->setPageLength(Commenting::get_config_value(null, 'comments_per_page'));
  120
+
  121
+		return new RSSFeed($comments, $link, $title, $link, 'Title', 'Comment', 'AuthorName');
109 122
 	}
110 123
 
111 124
 	/**
112 125
 	 * Deletes a given {@link Comment} via the URL.
113  
-	 *
114  
-	 * @param SS_HTTPRequest
115 126
 	 */
116  
-	public function delete($request) {
117  
-		if(!$this->checkSecurityToken($request)) {
  127
+	public function delete() {
  128
+		if(!$this->checkSecurityToken($this->request)) {
118 129
 			return $this->httpError(400);
119 130
 		}
120 131
 
@@ -129,11 +140,9 @@ public function delete($request) {
129 140
 
130 141
 	/**
131 142
 	 * Marks a given {@link Comment} as spam. Removes the comment from display
132  
-	 *
133  
-	 * @param SS_HTTPRequest
134 143
 	 */
135 144
 	public function spam() {
136  
-		if(!$this->checkSecurityToken($request)) {
  145
+		if(!$this->checkSecurityToken($this->request)) {
137 146
 			return $this->httpError(400);
138 147
 		}
139 148
 
@@ -152,11 +161,9 @@ public function spam() {
152 161
 
153 162
 	/**
154 163
 	 * Marks a given {@link Comment} as ham (not spam).
155  
-	 *
156  
-	 * @param SS_HTTPRequest
157 164
 	 */
158  
-	public function ham($request) {
159  
-		if(!$this->checkSecurityToken($request)) {
  165
+	public function ham() {
  166
+		if(!$this->checkSecurityToken($this->request)) {
160 167
 			return $this->httpError(400);
161 168
 		}
162 169
 
@@ -175,11 +182,9 @@ public function ham($request) {
175 182
 
176 183
 	/**
177 184
 	 * Marks a given {@link Comment} as approved.
178  
-	 *
179  
-	 * @param SS_HTTPRequest
180 185
 	 */
181  
-	public function approve($request) {
182  
-		if(!$this->checkSecurityToken($request)) {
  186
+	public function approve() {
  187
+		if(!$this->checkSecurityToken($this->request)) {
183 188
 			return $this->httpError(400);
184 189
 		}
185 190
 
@@ -197,7 +202,8 @@ public function approve($request) {
197 202
 	}
198 203
 	
199 204
 	/**
200  
-	 * Returns the comment referenced in the URL (by ID).
  205
+	 * Returns the comment referenced in the URL (by ID). Permission checking
  206
+	 * should be done in the callee.
201 207
 	 *
202 208
 	 * @return Comment|false
203 209
 	 */
@@ -370,15 +376,10 @@ public function doPostComment($data, $form) {
370 376
 			
371 377
 			return true;
372 378
 		}
373  
-		
374  
-		if($comment->NeedsModeration){
375  
-			$this->sessionMessage($moderationMsg, 'good');
376  
-		}
377  
-		
378  
-		// build up the return link. Ideally redirect to 
  379
+
379 380
 		$holder = Commenting::get_config_value($comment->BaseClass, 'comments_holder_id');
380 381
 
381  
-		$hash = ($comment->NeedsModeration) ? $holder : $comment->Permalink();
  382
+		$hash = ($moderated) ? $comment->Permalink() : $holder;
382 383
 		$url = (isset($data['ReturnURL'])) ? $data['ReturnURL'] : false;
383 384
 			
384 385
 		return ($url) ? $this->redirect($url .'#'. $hash) : $this->redirectBack();
32  code/dataobjects/Comment.php
@@ -29,7 +29,8 @@ class Comment extends DataObject {
29 29
 	public static $many_many = array();
30 30
 	
31 31
 	public static $defaults = array(
32  
-		"Moderated" => true
  32
+		"Moderated" => 1,
  33
+		"IsSpam" => 0
33 34
 	);
34 35
 	
35 36
 	public static $casting = array(
@@ -167,10 +168,9 @@ public function canView($member = null) {
167 168
 		if($extended !== null) return $extended;
168 169
 		
169 170
 		$page = $this->getParent();
170  
-		return (
171  
-			($page && $page->ProvideComments)
172  
-			|| (bool)Permission::checkMember($member, 'CMS_ACCESS_CommentAdmin')
173  
-		);
  171
+		$admin = (bool) Permission::checkMember($member, 'CMS_ACCESS_CommentAdmin');
  172
+
  173
+		return (($page && $page->ProvideComments && $page->canView($member)) || $admin);
174 174
 	}
175 175
 	
176 176
 	/**
@@ -229,9 +229,9 @@ public function DeleteLink() {
229 229
 		if($this->canDelete()) {
230 230
 			$token = SecurityToken::inst();
231 231
 
232  
-			return DBField::create_field("Varchar", $token->addToUrl(sprintf(
  232
+			return DBField::create_field("Varchar", Director::absoluteURL($token->addToUrl(sprintf(
233 233
 				"CommentingController/delete/%s", (int) $this->ID
234  
-			)));
  234
+			))));
235 235
 		}
236 236
 	}
237 237
 	
@@ -242,9 +242,9 @@ public function SpamLink() {
242 242
 		if($this->canEdit() && !$this->IsSpam) {
243 243
 			$token = SecurityToken::inst();
244 244
 
245  
-			return DBField::create_field("Varchar", $token->addToUrl(sprintf(
  245
+			return DBField::create_field("Varchar", Director::absoluteURL($token->addToUrl(sprintf(
246 246
 				"CommentingController/spam/%s", (int) $this->ID
247  
-			)));
  247
+			))));
248 248
 		}
249 249
 	}
250 250
 	
@@ -255,9 +255,9 @@ public function HamLink() {
255 255
 		if($this->canEdit() && $this->IsSpam) {
256 256
 			$token = SecurityToken::inst();
257 257
 
258  
-			return DBField::create_field("Varchar", $token->addToUrl(sprintf(
  258
+			return DBField::create_field("Varchar", Director::absoluteURL($token->addToUrl(sprintf(
259 259
 				"CommentingController/ham/%s", (int) $this->ID
260  
-			)));
  260
+			))));
261 261
 		}
262 262
 	}
263 263
 	
@@ -268,9 +268,9 @@ public function ApproveLink() {
268 268
 		if($this->canEdit() && !$this->Moderated) {
269 269
 			$token = SecurityToken::inst();
270 270
 
271  
-			return DBField::create_field("Varchar", $token->addToUrl(sprintf(
  271
+			return DBField::create_field("Varchar", Director::absoluteURL($token->addToUrl(sprintf(
272 272
 				"CommentingController/approve/%s", (int) $this->ID
273  
-			)));
  273
+			))));
274 274
 		}
275 275
 	}
276 276
 	
@@ -278,9 +278,9 @@ public function ApproveLink() {
278 278
 	 * @return string
279 279
 	 */
280 280
 	public function SpamClass() {
281  
-		if($this->getField('IsSpam')) {
  281
+		if($this->IsSpam) {
282 282
 			return 'spam';
283  
-		} else if($this->getField('NeedsModeration')) {
  283
+		} else if(!$this->Moderated) {
284 284
 			return 'unmoderated';
285 285
 		} else {
286 286
 			return 'notspam';
@@ -291,7 +291,7 @@ public function SpamClass() {
291 291
 	 * @return string
292 292
 	 */
293 293
 	public function getTitle() {
294  
-		$title = sprintf(_t('Comment.COMMENTBY', "Comment by '%s'", 'Name'), $this->getAuthorName());
  294
+		$title = sprintf(_t('Comment.COMMENTBY', "Comment by %s", 'Name'), $this->getAuthorName());
295 295
 
296 296
 		if($parent = $this->getParent()) {
297 297
 			if($parent->Title) {
7  code/extensions/CommentsExtension.php
@@ -65,6 +65,8 @@ public function updateSettingsFields(FieldList $fields) {
65 65
 	 * @return PaginatedList
66 66
 	 */
67 67
 	public function Comments() {
  68
+		$controller = Controller::curr();
  69
+
68 70
 		$order = Commenting::get_config_value($this->ownerBaseClass, 'order_comments_by');
69 71
 		
70 72
 		$list = new PaginatedList(Comment::get()->where(sprintf(
@@ -75,15 +77,14 @@ public function Comments() {
75 77
 			$this->ownerBaseClass, 'comments_per_page'
76 78
 		));
77 79
 
78  
-		$controller = Controller::curr();		
  80
+
  81
+		$controller = Controller::curr();	
79 82
 		$list->setPageStart($controller->request->getVar("commentsstart". $this->owner->ID));
80 83
 		$list->setPaginationGetVar("commentsstart". $this->owner->ID);
81  
-		$list->MoreThanOnePage();
82 84
 
83 85
 		return $list;
84 86
 	}
85 87
 	
86  
-	
87 88
 	/**
88 89
 	 * Comments interface for the front end. Includes the CommentAddForm and the composition
89 90
 	 * of the comments display. 
61  tests/CommentingControllerTests.php
... ...
@@ -0,0 +1,61 @@
  1
+<?php
  2
+
  3
+/**
  4
+ * @package comments
  5
+ * @subpackage tests
  6
+ */
  7
+class CommentingControllerTests extends FunctionalTest {
  8
+	
  9
+	public static $fixture_file = 'comments/tests/CommentsTest.yml';
  10
+
  11
+	protected $extraDataObjects = array(
  12
+		'CommentableItem'
  13
+	);
  14
+
  15
+	public function setUp() {
  16
+		parent::setUp();
  17
+
  18
+		Commenting::add('CommentableItem');
  19
+	}
  20
+
  21
+	public function testRSS() {
  22
+		$this->markTestIncomplete("Waiting for https://github.com/silverstripe/sapphire/pull/686 to land");
  23
+
  24
+		$item = $this->objFromFixture('CommentableItem', 'first');
  25
+
  26
+		// comments sitewide
  27
+		$response = $this->get('CommentingController/rss');
  28
+		$this->assertEquals(10, substr_count($response->getBody(), "<item>"), "10 approved, non spam comments on page 1");
  29
+
  30
+		$response = $this->get('CommentingController/rss?start=10');
  31
+		$this->assertEquals(3, substr_count($response->getBody(), "<item>"), "3 approved, non spam comments on page 2");
  32
+
  33
+		// all comments on a type
  34
+		$response = $this->get('CommentingController/rss/CommentableItem');
  35
+		$this->assertEquals(10, substr_count($response->getBody(), "<item>"));
  36
+
  37
+		$response = $this->get('CommentingController/rss/CommentableItem?start=10');
  38
+		$this->assertEquals(3, substr_count($response->getBody(), "<item>"), "3 approved, non spam comments on page 2");
  39
+
  40
+		// specific page
  41
+		$response = $this->get('CommentingController/rss/CommentableItem/'.$item->ID);
  42
+		$this->assertEquals(1, substr_count($response->getBody(), "<item>"));
  43
+		$this->assertContains('<dc:creator>FA</dc:creator>', $response->getBody());
  44
+
  45
+		// test accessing comments on a type that doesn't exist
  46
+		$response = $this->get('CommentingController/rss/Fake');
  47
+		$this->assertEquals(404, $response->getStatusCode());
  48
+	}
  49
+
  50
+	public function testRSSSecuredCommentsForm() {
  51
+		$this->markTestIncomplete("Not implemented");
  52
+	}
  53
+
  54
+	public function testCommentsForm() {
  55
+		$this->markTestIncomplete("Not implemented");
  56
+	}
  57
+
  58
+	public function testDoCommentsForm() {
  59
+		$this->markTestIncomplete("Not implemented");
  60
+	}
  61
+}
147  tests/CommentsTest.php
@@ -5,15 +5,26 @@
5 5
  */
6 6
 class CommentsTest extends FunctionalTest {
7 7
 	
8  
-	static $fixture_file = 'comments/tests/CommentsTest.yml';
  8
+	public static $fixture_file = 'comments/tests/CommentsTest.yml';
9 9
 	
10  
-	function testCanView() {
  10
+	protected $extraDataObjects = array(
  11
+		'CommentableItem'
  12
+	);
  13
+
  14
+	public function setUp() {
  15
+		parent::setUp();
  16
+
  17
+		Commenting::add('CommentableItem');
  18
+	}
  19
+	
  20
+
  21
+	public function testCanView() {
11 22
 		$visitor = $this->objFromFixture('Member', 'visitor');
12 23
 		$admin = $this->objFromFixture('Member', 'commentadmin');
13 24
 		$comment = $this->objFromFixture('Comment', 'firstComA');
14  
-		
  25
+
15 26
 		$this->assertTrue($comment->canView($visitor), 
16  
-			'Unauthenticated members can view comments associated to a page with ProvideComments=1'
  27
+			'Unauthenticated members can view comments associated to a object with ProvideComments=1'
17 28
 		);
18 29
 		$this->assertTrue($comment->canView($admin),
19 30
 			'Admins with CMS_ACCESS_CommentAdmin permissions can view comments associated to a page with ProvideComments=1'
@@ -22,14 +33,15 @@ function testCanView() {
22 33
 		$disabledComment = $this->objFromFixture('Comment', 'disabledCom');
23 34
 		
24 35
 		$this->assertFalse($disabledComment->canView($visitor),
25  
-		'Unauthenticated members can not view comments associated to a page with ProvideComments=0'
  36
+			'Unauthenticated members can not view comments associated to a object with ProvideComments=0'
26 37
 		);
  38
+
27 39
 		$this->assertTrue($disabledComment->canView($admin),
28 40
 			'Admins with CMS_ACCESS_CommentAdmin permissions can view comments associated to a page with ProvideComments=0'
29 41
 		);
30 42
 	}
31 43
 	
32  
-	function testCanEdit() {
  44
+	public function testCanEdit() {
33 45
 		$visitor = $this->objFromFixture('Member', 'visitor');
34 46
 		$admin = $this->objFromFixture('Member', 'commentadmin');
35 47
 		$comment = $this->objFromFixture('Comment', 'firstComA');
@@ -38,7 +50,7 @@ function testCanEdit() {
38 50
 		$this->assertTrue($comment->canEdit($admin));
39 51
 	}
40 52
 	
41  
-	function testCanDelete() {
  53
+	public function testCanDelete() {
42 54
 		$visitor = $this->objFromFixture('Member', 'visitor');
43 55
 		$admin = $this->objFromFixture('Member', 'commentadmin');
44 56
 		$comment = $this->objFromFixture('Comment', 'firstComA');
@@ -47,8 +59,14 @@ function testCanDelete() {
47 59
 		$this->assertTrue($comment->canEdit($admin));
48 60
 	}
49 61
 	
50  
-	function testDeleteComment() {
51  
-		$firstPage = $this->objFromFixture('Page', 'first');
  62
+	public function testDeleteComment() {
  63
+		$comment = $this->objFromFixture('Comment', 'firstComA');
  64
+		$this->assertNull($comment->DeleteLink(), 'No permission to see delete link');
  65
+		$delete = $this->get('CommentingController/delete/'.$comment->ID);
  66
+		$check = DataObject::get_by_id('Comment', $comment->ID);
  67
+		$this->assertTrue($check && $check->exists());
  68
+
  69
+		$firstPage = $this->objFromFixture('CommentableItem', 'first');
52 70
 		$this->autoFollowRedirection = false;
53 71
 		$this->logInAs('commentadmin');
54 72
 		
@@ -56,11 +74,71 @@ function testDeleteComment() {
56 74
 		$firstCommentID = $firstComment->ID;
57 75
 		Director::test($firstPage->RelativeLink(), null, $this->session());
58 76
 		$delete = $this->get('CommentingController/delete/'.$firstComment->ID);
59  
-	
60  
-		$this->assertFalse(DataObject::get_by_id('Comment', $firstCommentID));
  77
+		$check = DataObject::get_by_id('Comment', $firstCommentID);
  78
+		$this->assertFalse($check && $check->exists());
  79
+	}
  80
+
  81
+	public function testSpamComment() {
  82
+		$comment = $this->objFromFixture('Comment', 'firstComA');
  83
+		$this->assertNull($comment->SpamLink(), 'No permission to see mark as spam link');
  84
+		$spam = $this->get('CommentingController/spam/'.$comment->ID);
  85
+
  86
+		$check = DataObject::get_by_id('Comment', $comment->ID);
  87
+		$this->assertEquals(0, $check->IsSpam, 'No permission to mark as spam');
  88
+
  89
+		$this->autoFollowRedirection = false;
  90
+		$this->logInAs('commentadmin');
  91
+
  92
+		$this->assertContains('CommentingController/spam/'. $comment->ID, $comment->SpamLink()->getValue());
  93
+
  94
+		$spam = $this->get('CommentingController/spam/'.$comment->ID);
  95
+		$check = DataObject::get_by_id('Comment', $comment->ID);
  96
+		$this->assertEquals(1, $check->IsSpam);
  97
+
  98
+		$this->assertNull($check->SpamLink());
  99
+	}
  100
+
  101
+	public function testHamComment() {
  102
+		$comment = $this->objFromFixture('Comment', 'secondComC');
  103
+		$this->assertNull($comment->HamLink(), 'No permission to see mark as ham link');
  104
+		$ham = $this->get('CommentingController/ham/'.$comment->ID);
  105
+
  106
+		$check = DataObject::get_by_id('Comment', $comment->ID);
  107
+		$this->assertEquals(1, $check->IsSpam, 'No permission to mark as ham');
  108
+
  109
+		$this->autoFollowRedirection = false;
  110
+		$this->logInAs('commentadmin');
  111
+
  112
+		$this->assertContains('CommentingController/ham/'. $comment->ID, $comment->HamLink()->getValue());
  113
+
  114
+		$ham = $this->get('CommentingController/ham/'.$comment->ID);
  115
+		$check = DataObject::get_by_id('Comment', $comment->ID);
  116
+		$this->assertEquals(0, $check->IsSpam);
  117
+
  118
+		$this->assertNull($check->HamLink());
61 119
 	}
62 120
 	
63  
-	function testCommenterURLWrite() {
  121
+	public function testApproveComment() {
  122
+		$comment = $this->objFromFixture('Comment', 'secondComB');
  123
+		$this->assertNull($comment->ApproveLink(), 'No permission to see mark as approved link');
  124
+		$ham = $this->get('CommentingController/approve/'.$comment->ID);
  125
+
  126
+		$check = DataObject::get_by_id('Comment', $comment->ID);
  127
+		$this->assertEquals(0, $check->Moderated, 'No permission to mark as approved');
  128
+
  129
+		$this->autoFollowRedirection = false;
  130
+		$this->logInAs('commentadmin');
  131
+
  132
+		$this->assertContains('CommentingController/approve/'. $comment->ID, $comment->ApproveLink()->getValue());
  133
+
  134
+		$ham = $this->get('CommentingController/approve/'.$comment->ID);
  135
+		$check = DataObject::get_by_id('Comment', $comment->ID);
  136
+		$this->assertEquals(1, $check->Moderated);
  137
+
  138
+		$this->assertNull($check->ApproveLink());
  139
+	}
  140
+
  141
+	public function testCommenterURLWrite() {
64 142
 		$comment = new Comment();
65 143
 		// We only care about the CommenterURL, so only set that
66 144
 		// Check a http and https URL. Add more test urls here as needed.
@@ -69,6 +147,7 @@ function testCommenterURLWrite() {
69 147
 			'Https',
70 148
 		);
71 149
 		$url = '://example.com';
  150
+
72 151
 		foreach($protocols as $protocol) {
73 152
 			$comment->CommenterURL = $protocol . $url;
74 153
 			// The protocol should stay as if, assuming it is valid
@@ -77,3 +156,47 @@ function testCommenterURLWrite() {
77 156
 		}
78 157
 	}
79 158
 }
  159
+
  160
+
  161
+/**
  162
+ * @package comments
  163
+ * @subpackage tests
  164
+ */
  165
+class CommentableItem extends DataObject implements TestOnly {
  166
+
  167
+	public static $db = array(
  168
+		'ProvideComments' => 'Boolean',
  169
+		'Title' => 'Varchar'
  170
+	);
  171
+
  172
+	public function RelativeLink() {
  173
+		return "CommentableItem_Controller";
  174
+	}
  175
+
  176
+	public function canView($member = null) {
  177
+		return true;
  178
+	}
  179
+
  180
+	public function Link() {
  181
+		return $this->RelativeLink();
  182
+	}
  183
+
  184
+	public function AbsoluteLink() {
  185
+		return Director::absoluteURL($this->RelativeLink());
  186
+	}
  187
+}
  188
+
  189
+/**
  190
+ * @package comments
  191
+ * @subpackage tests
  192
+ */
  193
+class CommentableItem_Controller extends Controller implements TestOnly {
  194
+	
  195
+	public static $allowed_actions = array(
  196
+		"*" => true
  197
+	);
  198
+	
  199
+	public function index() {
  200
+		return CommentableItem::get()->first()->CommentsForm();
  201
+	}
  202
+}
110  tests/CommentsTest.yml
@@ -14,59 +14,127 @@ Permission:
14 14
 		Code: CMS_ACCESS_CommentAdmin
15 15
 		Group: =>Group.commentadmins
16 16
 
17  
-Page:
  17
+CommentableItem:
18 18
 	first:
19  
-		Title: First page
20  
-		URLSegment: first-page
  19
+		Title: First
21 20
 		ProvideComments: 1
22 21
 	second:
23  
-		Title: Second page
24  
-		URLSegment: second-page
  22
+		Title: Second
25 23
  		ProvideComments: 1
26 24
 	third:
27  
-		Title: Third page
28  
-		URLSegment:third-page
  25
+		Title: Third
29 26
 		ProvideComments: 1
30  
-	pageNoComments:
  27
+	nocomments:
31 28
 		Title: No comments
32  
-		URLSegment: no-comments
33 29
 		ProvideComments: 0
34 30
 
35 31
 Comment:
36 32
 	firstComA:
37  
-		ParentID: =>Page.first
  33
+		ParentID: =>CommentableItem.first
38 34
 		Name: FA
39 35
 		Comment: textFA
  36
+		BaseClass: CommentableItem
40 37
 		Moderated: 1
  38
+		IsSpam: 0
41 39
 	secondComA:
42  
-		ParentID: =>Page.second
  40
+		ParentID: =>CommentableItem.second
43 41
 		Name: SA
44 42
 		Comment: textSA
45 43
 		Moderated: 1
  44
+		IsSpam: 0
  45
+		BaseClass: CommentableItem
46 46
 	secondComB:
47  
-		ParentID: =>Page.second
  47
+		ParentID: =>CommentableItem.second
  48
+		Name: SB
  49
+		Comment: textSB
  50
+		Moderated: 0
  51
+		IsSpam: 0
  52
+		BaseClass: CommentableItem
  53
+	secondComC:
  54
+		ParentID: =>CommentableItem.second
48 55
 		Name: SB
49 56
 		Comment: textSB
50 57
 		Moderated: 1
  58
+		IsSpam: 1
  59
+		BaseClass: CommentableItem
51 60
 	thirdComA:
52  
-		ParentID: =>Page.third
  61
+		ParentID: =>CommentableItem.third
53 62
 		Name: TA
54 63
 		Comment: textTA
55 64
 		Moderated: 1
56  
-		IsSpam: 1
  65
+		IsSpam: 0
  66
+		BaseClass: CommentableItem
57 67
 	thirdComB:
58  
-		ParentID: =>Page.third
  68
+		ParentID: =>CommentableItem.third
59 69
 		Name: TB
60 70
 		Comment: textTB
61  
-		Moderated: 0
  71
+		Moderated: 1
  72
+		IsSpam: 0
  73
+		BaseClass: CommentableItem
62 74
 	thirdComC:
63  
-		ParentID: =>Page.third
  75
+		ParentID: =>CommentableItem.third
64 76
 		Name: TC
65 77
 		Comment: textTC
66  
-		Moderated: 0
67  
-		
  78
+		Moderated: 1
  79
+		IsSpam: 0
  80
+		BaseClass: CommentableItem
  81
+	thirdComD:
  82
+		ParentID: =>CommentableItem.third
  83
+		Name: TC
  84
+		Comment: textTC
  85
+		Moderated: 1
  86
+		BaseClass: CommentableItem
  87
+	thirdComE:
  88
+		ParentID: =>CommentableItem.third
  89
+		Name: TC
  90
+		Comment: textTC
  91
+		Moderated: 1
  92
+		BaseClass: CommentableItem
  93
+	thirdComF:
  94
+		ParentID: =>CommentableItem.third
  95
+		Name: TC
  96
+		Comment: textTC
  97
+		Moderated: 1
  98
+		IsSpam: 0
  99
+		BaseClass: CommentableItem
  100
+	thirdComG:
  101
+		ParentID: =>CommentableItem.third
  102
+		Name: TC
  103
+		Comment: textTC
  104
+		Moderated: 1
  105
+		IsSpam: 0
  106
+		BaseClass: CommentableItem
  107
+	thirdComH:
  108
+		ParentID: =>CommentableItem.third
  109
+		Name: TC
  110
+		Comment: textTC
  111
+		Moderated: 1
  112
+		IsSpam: 0
  113
+		BaseClass: CommentableItem
  114
+	thirdComI:
  115
+		ParentID: =>CommentableItem.third
  116
+		Name: TC
  117
+		Comment: textTC
  118
+		Moderated: 1
  119
+		IsSpam: 0
  120
+		BaseClass: CommentableItem
  121
+	thirdComJ:
  122
+		ParentID: =>CommentableItem.third
  123
+		Name: TC
  124
+		Comment: textTC
  125
+		Moderated: 1
  126
+		IsSpam: 0
  127
+		BaseClass: CommentableItem
  128
+	thirdComK:
  129
+		ParentID: =>CommentableItem.third
  130
+		Name: TC
  131
+		Comment: textTC
  132
+		Moderated: 1
  133
+		IsSpam: 0
  134
+		BaseClass: CommentableItem						
68 135
 	disabledCom:
69  
-		ParentID: =>Page.pageNoComments
  136
+		ParentID: =>CommentableItem.nocomments
70 137
 		Name: Disabled
71 138
 		Moderated: 0
72  
-		IsSpam: 1
  139
+		IsSpam: 1
  140
+		BaseClass: CommentableItem

0 notes on commit 6d35970

Please sign in to comment.
Something went wrong with that request. Please try again.