| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | class CommentsExtensionTest extends SapphireTest { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |     public static $fixture_file = 'comments/tests/CommentsTest.yml'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |     protected $extraDataObjects = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |         'CommentableItem', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |         'CommentableItemEnabled', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |         'CommentableItemDisabled' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 13 |  | View Code Duplication |     public function setUp() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |         Config::nest(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |         // Set good default values | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |         Config::inst()->update('CommentsExtension', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |             'enabled' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |             'enabled_cms' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |             'require_login' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |             'require_login_cms' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |             'required_permission' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |             'require_moderation_nonmembers' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |             'require_moderation' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |             'require_moderation_cms' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |             'frontend_moderation' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |             'Member' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->requiredExtensions = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |             'CommentableItem' => 'CommentsExtension' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         // Configure this dataobject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             'enabled_cms' => true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     public function tearDown() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         Config::unnest(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         parent::tearDown(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	public function testPopulateDefaults() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 		$this->markTestSkipped('TODO'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	public function testUpdateSettingsFields() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $this->markTestSkipped('This needs SiteTree installed'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	public function testGetModerationRequired() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         // the 3 options take precedence in this order, executed if true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             'require_moderation_cms' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             'require_moderation' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             'require_moderation_nonmembers' => true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         // With require moderation CMS set to true, the value of the field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         // 'ModerationRequired' is returned | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $item = $this->objFromFixture('CommentableItem', 'first'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $item->ModerationRequired = 'None'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         $this->assertEquals('None', $item->getModerationRequired()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $item->ModerationRequired = 'Required'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->assertEquals('Required', $item->getModerationRequired()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $item->ModerationRequired = 'NonMembersOnly'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $this->assertEquals('NonMembersOnly', $item->getModerationRequired()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             'require_moderation_cms' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             'require_moderation' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             'require_moderation_nonmembers' => true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         $this->assertEquals('Required', $item->getModerationRequired()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             'require_moderation_cms' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             'require_moderation' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             'require_moderation_nonmembers' => true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $this->assertEquals('NonMembersOnly', $item->getModerationRequired()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |             'require_moderation_cms' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             'require_moderation' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |             'require_moderation_nonmembers' => false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $this->assertEquals('None', $item->getModerationRequired()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	public function testGetCommentsRequireLogin() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 		Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             'require_login_cms' => true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         // With require moderation CMS set to true, the value of the field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         // 'ModerationRequired' is returned | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $item = $this->objFromFixture('CommentableItem', 'first'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $item->CommentsRequireLogin = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $this->assertTrue($item->getCommentsRequireLogin()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $item->CommentsRequireLogin = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         $this->assertFalse($item->getCommentsRequireLogin()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             'require_login_cms' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             'require_login' => false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         $this->assertFalse($item->getCommentsRequireLogin()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             'require_login_cms' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             'require_login' => true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |         $this->assertTrue($item->getCommentsRequireLogin()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 	public function testAllComments() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 		$this->markTestSkipped('TODO'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 	public function testAllVisibleComments() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		$this->markTestSkipped('TODO'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 	public function testComments() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 		$this->markTestSkipped('TODO'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 	public function testGetCommentsEnabled() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 		$this->markTestSkipped('TODO'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	public function testGetCommentHolderID() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         $item = $this->objFromFixture('CommentableItem', 'first'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             'comments_holder_id' => 'commentid_test1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         $this->assertEquals('commentid_test1', $item->getCommentHolderID()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |             'comments_holder_id' => 'commtentid_test_another', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         $this->assertEquals('commtentid_test_another', $item->getCommentHolderID()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 	public function testGetPostingRequiredPermission() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 		$this->markTestSkipped('TODO'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 	public function testCanModerateComments() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         // ensure nobody logged in | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         if(Member::currentUser()) { Member::currentUser()->logOut(); } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 		$item = $this->objFromFixture('CommentableItem', 'first'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         $this->assertFalse($item->canModerateComments()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         $this->logInWithPermission('CMS_ACCESS_CommentAdmin'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         $this->assertTrue($item->canModerateComments()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 	public function testGetCommentRSSLink() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 	   $item = $this->objFromFixture('CommentableItem', 'first'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |        $link = $item->getCommentRSSLink(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |        $this->assertEquals('/CommentingController/rss', $link); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 	public function testGetCommentRSSLinkPage() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 		$item = $this->objFromFixture('CommentableItem', 'first'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         $page = $item->getCommentRSSLinkPage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |         $this->assertEquals( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |             '/CommentingController/rss/CommentableItem/' . $item->ID, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |             $page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 	public function testCommentsForm() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |             'include_js' => false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 		$item = $this->objFromFixture('CommentableItem', 'first'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         // The comments form is HTML to do assertions by contains | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         $cf = $item->CommentsForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         $expected = '<form id="Form_CommentsForm" action="/CommentingController' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         . '/CommentsForm" method="post" enctype="application/x-www-form-urlenco' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         . 'ded">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         $this->assertContains('<h4>Post your comment</h4>', $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         // check the comments form exists | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         $expected = '<input type="text" name="Name" value="ADMIN User" class="text" id="Form_CommentsForm_Name" required="required"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         $expected = '<input type="email" name="Email" value="[email protected]" class="email text" id="Form_CommentsForm_Email"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         $expected = '<input type="text" name="URL" class="text" id="Form_CommentsForm_URL" data-msg-url="Please enter a valid URL"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         $expected = '<input type="hidden" name="ParentID" value="' . $item->ID . '" class="hidden" id="Form_CommentsForm_ParentID" />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |         $expected = '<textarea name="Comment" class="textarea" id="Form_CommentsForm_Comment" required="required"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |         $expected = '<input type="submit" name="action_doPostComment" value="Post" class="action" id="Form_CommentsForm_action_doPostComment"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         $expected = '<a href="/CommentingController/spam/'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         $expected = '<p>Reply to firstComA 1</p>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         $expected = '<a href="/CommentingController/delete'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         $expected = '<p>Reply to firstComA 2</p>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |         $expected = '<p>Reply to firstComA 3</p>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |         $this->assertContains($expected, $cf); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |         // Check for JS inclusion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         $backend = Requirements::backend(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         $this->assertEquals( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |             array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |             $backend->get_javascript() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |             'include_js' => true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         $cf = $item->CommentsForm(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |         $backend = Requirements::backend(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         $this->assertEquals( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |                 'framework/thirdparty/jquery/jquery.js', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |                 'framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |                 'framework/thirdparty/jquery-validate/lib/jquery.form.js', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |                 'comments/thirdparty/jquery-validate/jquery.validate.min.js', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |                 'framework/javascript/i18n.js', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |                 'comments/javascript/lang/en.js', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |                 'comments/javascript/CommentsInterface.js' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |             $backend->get_javascript() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 	public function testAttachedToSiteTree() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 		$this->markTestSkipped('TODO'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 	public function testPagedComments() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |         $item = $this->objFromFixture('CommentableItem', 'first'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |         // Ensure Created times are set, as order not guaranteed if all set to 0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |         $comments = $item->PagedComments()->sort('ID'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |         $ctr = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |         $timeBase = time()-10000; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |         foreach ($comments as $comment) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |             $comment->Created = $timeBase + $ctr * 1000; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |             $comment->write(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |             $ctr++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |         $results = $item->PagedComments()->toArray(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         foreach ($results as $result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |            $result->sourceQueryParams = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |         $this->assertEquals( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |             $this->objFromFixture('Comment', 'firstComA')->Comment, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |             $results[3]->Comment | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |         $this->assertEquals( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |             $this->objFromFixture('Comment', 'firstComAChild1')->Comment, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |             $results[2]->Comment | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |         $this->assertEquals( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |             $this->objFromFixture('Comment', 'firstComAChild2')->Comment, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |             $results[1]->Comment | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |         $this->assertEquals( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |             $this->objFromFixture('Comment', 'firstComAChild3')->Comment, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |             $results[0]->Comment | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |         $this->assertEquals(4, sizeof($results)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 	public function testGetCommentsOption() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 		$this->markTestSkipped('TODO'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 	public function testUpdateModerationFields() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 		$this->markTestSkipped('TODO'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 309 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 310 |  |  | 	public function testUpdateCMSFields() { | 
            
                                                                        
                            
            
                                    
            
            
                | 311 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                        
                            
            
                                    
            
            
                | 312 |  |  |             'require_login_cms' => false | 
            
                                                                        
                            
            
                                    
            
            
                | 313 |  |  |             ) | 
            
                                                                        
                            
            
                                    
            
            
                | 314 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 315 |  |  |         $this->logInWithPermission('ADMIN'); | 
            
                                                                        
                            
            
                                    
            
            
                | 316 |  |  | 		$item = $this->objFromFixture('CommentableItem', 'first'); | 
            
                                                                        
                            
            
                                    
            
            
                | 317 |  |  |         $item->ProvideComments = true; | 
            
                                                                        
                            
            
                                    
            
            
                | 318 |  |  |         $item->write(); | 
            
                                                                        
                            
            
                                    
            
            
                | 319 |  |  |         $fields = $item->getCMSFields(); | 
            
                                                                        
                            
            
                                    
            
            
                | 320 |  |  |         CommentTestHelper::assertFieldsForTab($this, 'Root.Comments', | 
            
                                                                        
                            
            
                                    
            
            
                | 321 |  |  |             array('CommentsNewCommentsTab', 'CommentsCommentsTab', 'CommentsSpamCommentsTab'), | 
            
                                                                        
                            
            
                                    
            
            
                | 322 |  |  |             $fields | 
            
                                                                        
                            
            
                                    
            
            
                | 323 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 324 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 325 |  |  |         CommentTestHelper::assertFieldsForTab($this, 'Root.Comments.CommentsNewCommentsTab', | 
            
                                                                        
                            
            
                                    
            
            
                | 326 |  |  |             array('NewComments'), | 
            
                                                                        
                            
            
                                    
            
            
                | 327 |  |  |             $fields | 
            
                                                                        
                            
            
                                    
            
            
                | 328 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 329 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 330 |  |  |         CommentTestHelper::assertFieldsForTab($this, 'Root.Comments.CommentsCommentsTab', | 
            
                                                                        
                            
            
                                    
            
            
                | 331 |  |  |             array('ApprovedComments'), | 
            
                                                                        
                            
            
                                    
            
            
                | 332 |  |  |             $fields | 
            
                                                                        
                            
            
                                    
            
            
                | 333 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 334 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 335 |  |  |         CommentTestHelper::assertFieldsForTab($this,  'Root.Comments.CommentsSpamCommentsTab', | 
            
                                                                        
                            
            
                                    
            
            
                | 336 |  |  |             array('SpamComments'), | 
            
                                                                        
                            
            
                                    
            
            
                | 337 |  |  |             $fields | 
            
                                                                        
                            
            
                                    
            
            
                | 338 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 339 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 340 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                        
                            
            
                                    
            
            
                | 341 |  |  |             'require_login_cms' => true | 
            
                                                                        
                            
            
                                    
            
            
                | 342 |  |  |             ) | 
            
                                                                        
                            
            
                                    
            
            
                | 343 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 344 |  |  |         $fields = $item->getCMSFields(); | 
            
                                                                        
                            
            
                                    
            
            
                | 345 |  |  |         CommentTestHelper::assertFieldsForTab($this, 'Root.Settings', array('Comments'), $fields); | 
            
                                                                        
                            
            
                                    
            
            
                | 346 |  |  |         $settingsTab = $fields->findOrMakeTab('Root.Settings'); | 
            
                                                                        
                            
            
                                    
            
            
                | 347 |  |  |         $settingsChildren = $settingsTab->getChildren(); | 
            
                                                                        
                            
            
                                    
            
            
                | 348 |  |  |         $this->assertEquals(1, $settingsChildren->count()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 349 |  |  |         $fieldGroup = $settingsChildren->first(); | 
            
                                                                        
                            
            
                                    
            
            
                | 350 |  |  |         $fields = $fieldGroup->getChildren(); | 
            
                                                                        
                            
            
                                    
            
            
                | 351 |  |  |         CommentTestHelper::assertFieldNames( | 
            
                                                                        
                            
            
                                    
            
            
                | 352 |  |  |             $this, | 
            
                                                                        
                            
            
                                    
            
            
                | 353 |  |  |             array('ProvideComments', 'CommentsRequireLogin'), | 
            
                                                                        
                            
            
                                    
            
            
                | 354 |  |  |             $fields | 
            
                                                                        
                            
            
                                    
            
            
                | 355 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 356 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 357 |  |  |         Config::inst()->update('CommentableItem', 'comments', array( | 
            
                                                                        
                            
            
                                    
            
            
                | 358 |  |  |             'require_login_cms' => true, | 
            
                                                                        
                            
            
                                    
            
            
                | 359 |  |  |             'require_moderation_cms' => true | 
            
                                                                        
                            
            
                                    
            
            
                | 360 |  |  |             ) | 
            
                                                                        
                            
            
                                    
            
            
                | 361 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 362 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 363 |  |  |         $fields = $item->getCMSFields(); | 
            
                                                                        
                            
            
                                    
            
            
                | 364 |  |  |         CommentTestHelper::assertFieldsForTab( | 
            
                                                                        
                            
            
                                    
            
            
                | 365 |  |  |             $this, | 
            
                                                                        
                            
            
                                    
            
            
                | 366 |  |  |             'Root.Settings', | 
            
                                                                        
                            
            
                                    
            
            
                | 367 |  |  |             array('Comments', 'ModerationRequired'), $fields | 
            
                                                                        
                            
            
                                    
            
            
                | 368 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 369 |  |  |         $settingsTab = $fields->findOrMakeTab('Root.Settings'); | 
            
                                                                        
                            
            
                                    
            
            
                | 370 |  |  |         $settingsChildren = $settingsTab->getChildren(); | 
            
                                                                        
                            
            
                                    
            
            
                | 371 |  |  |         $this->assertEquals(2, $settingsChildren->count()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 372 |  |  |         $fieldGroup = $settingsChildren->first(); | 
            
                                                                        
                            
            
                                    
            
            
                | 373 |  |  |         $fields = $fieldGroup->getChildren(); | 
            
                                                                        
                            
            
                                    
            
            
                | 374 |  |  |         CommentTestHelper::assertFieldNames( | 
            
                                                                        
                            
            
                                    
            
            
                | 375 |  |  |             $this, | 
            
                                                                        
                            
            
                                    
            
            
                | 376 |  |  |             array('ProvideComments', 'CommentsRequireLogin'), | 
            
                                                                        
                            
            
                                    
            
            
                | 377 |  |  |             $fields | 
            
                                                                        
                            
            
                                    
            
            
                | 378 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 379 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |     public function testDeprecatedMethods() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |         $item = $this->objFromFixture('CommentableItem', 'first'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |         $methodNames = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |             'getRssLinkPage', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |             'getRssLink', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |             'PageComments', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |             'getPostingRequiresPermission', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |             'canPost', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |             'getCommentsConfigured' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |         foreach ($methodNames as $methodName) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |             try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |                 $item->$methodName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |                 $this->fail('Method ' . $methodName .' should be depracated'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |             } catch (PHPUnit_Framework_Error_Deprecated $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |                 $expected = 'CommentsExtension->' . $methodName . ' is '. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |                 'deprecated.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |                 $this->assertStringStartsWith($expected, $e->getMessage()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |         // ooh,  $this->setExpectedException('ExpectedException', 'Expected Message'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 409 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 410 |  |  |  | 
            
                        
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.