Changeset 7127
- Timestamp:
- 05/29/2013 12:34:35 AM (12 years ago)
- Location:
- trunk/tests/testcases/activity
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/testcases/activity/class.BP_Activity_Activity.php
r7126 r7127 113 113 114 114 /** 115 * @group get 116 */ 117 public function test_get_with_display_comments_threaded() { 118 $now = time(); 119 $a1 = $this->factory->activity->create( array( 120 'content' => 'Life Rules', 121 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 122 ) ); 123 $a2 = $this->factory->activity->create( array( 124 'content' => 'Life Drools', 125 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 126 ) ); 127 $a3 = bp_activity_new_comment( array( 128 'activity_id' => $a1, 129 'content' => 'Candy is good', 130 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 131 ) ); 132 133 $activity = BP_Activity_Activity::get( array( 134 'display_comments' => 'threaded', 135 ) ); 136 137 // Kinda crummy, but let's construct a skeleton 138 $expected = array( 139 $a1 => array( $a3 ), 140 $a2 => array(), 141 ); 142 143 $found = array(); 144 foreach ( $activity['activities'] as $a ) { 145 $found[ $a->id ] = ! empty( $a->children ) ? array_keys( $a->children ) : array(); 146 } 147 148 $this->assertEquals( $expected, $found ); 149 } 150 151 /** 152 * @group get 153 */ 154 public function test_get_with_display_comments_stream() { 155 $now = time(); 156 $a1 = $this->factory->activity->create( array( 157 'content' => 'Life Rules', 158 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 159 ) ); 160 $a2 = $this->factory->activity->create( array( 161 'content' => 'Life Drools', 162 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 163 ) ); 164 $a3 = bp_activity_new_comment( array( 165 'activity_id' => $a1, 166 'content' => 'Candy is good', 167 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 168 ) ); 169 170 $activity = BP_Activity_Activity::get( array( 171 'display_comments' => 'stream', 172 ) ); 173 $ids = wp_list_pluck( $activity['activities'], 'id' ); 174 $this->assertEquals( array( $a1, $a3, $a2 ), $ids ); 175 } 176 177 /** 178 * @group get 179 */ 180 public function test_get_with_display_comments_false() { 181 $now = time(); 182 $a1 = $this->factory->activity->create( array( 183 'content' => 'Life Rules', 184 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 185 ) ); 186 $a2 = $this->factory->activity->create( array( 187 'content' => 'Life Drools', 188 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 189 ) ); 190 $a3 = bp_activity_new_comment( array( 191 'activity_id' => $a1, 192 'content' => 'Candy is good', 193 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 194 ) ); 195 196 $activity = BP_Activity_Activity::get( array( 197 'display_comments' => false, 198 ) ); 199 $ids = wp_list_pluck( $activity['activities'], 'id' ); 200 $this->assertEquals( array( $a1, $a2 ), $ids ); 201 } 202 203 /** 115 204 * @group get_id 116 205 */ -
trunk/tests/testcases/activity/template.php
r7107 r7127 138 138 $this->assertEquals( $ids, array( $a1 ) ); 139 139 } 140 141 /** 142 * @ticket BP5029 143 * @group bp_has_activities 144 */ 145 public function test_bp_has_activities_with_display_comments_false() { 146 $now = time(); 147 $a1 = $this->factory->activity->create( array( 148 'content' => 'Life Rules', 149 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 150 ) ); 151 $a2 = $this->factory->activity->create( array( 152 'content' => 'Life Drools', 153 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 154 ) ); 155 $a3 = bp_activity_new_comment( array( 156 'activity_id' => $a1, 157 'content' => 'Candy is good', 158 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 159 ) ); 160 161 global $activities_template; 162 bp_has_activities( array( 163 'display_comments' => false, 164 ) ); 165 $ids = wp_list_pluck( $activities_template->activities, 'id' ); 166 167 $this->assertEquals( array( $a1, $a2 ), wp_parse_id_list( $ids ) ); 168 169 } 170 171 /** 172 * @ticket BP5029 173 * @group bp_has_activities 174 */ 175 public function test_bp_has_activities_with_display_comments_0() { 176 $now = time(); 177 $a1 = $this->factory->activity->create( array( 178 'content' => 'Life Rules', 179 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 180 ) ); 181 $a2 = $this->factory->activity->create( array( 182 'content' => 'Life Drools', 183 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 184 ) ); 185 $a3 = bp_activity_new_comment( array( 186 'activity_id' => $a1, 187 'content' => 'Candy is good', 188 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 189 ) ); 190 191 global $activities_template; 192 bp_has_activities( array( 193 'display_comments' => 0, 194 ) ); 195 $ids = wp_list_pluck( $activities_template->activities, 'id' ); 196 197 $this->assertEquals( array( $a1, $a2 ), wp_parse_id_list( $ids ) ); 198 199 } 200 201 /** 202 * @ticket BP5029 203 * @group bp_has_activities 204 */ 205 public function test_bp_has_activities_with_display_comments_0_querystring() { 206 $now = time(); 207 $a1 = $this->factory->activity->create( array( 208 'content' => 'Life Rules', 209 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 210 ) ); 211 $a2 = $this->factory->activity->create( array( 212 'content' => 'Life Drools', 213 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 214 ) ); 215 $a3 = bp_activity_new_comment( array( 216 'activity_id' => $a1, 217 'content' => 'Candy is good', 218 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 219 ) ); 220 221 global $activities_template; 222 bp_has_activities( 'display_comments=0' ); 223 $ids = wp_list_pluck( $activities_template->activities, 'id' ); 224 225 $this->assertEquals( array( $a1, $a2 ), $ids ); 226 227 } 228 229 /** 230 * @ticket BP5029 231 * @group bp_has_activities 232 */ 233 public function test_bp_has_activities_with_display_comments_none_querystring() { 234 $now = time(); 235 $a1 = $this->factory->activity->create( array( 236 'content' => 'Life Rules', 237 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 238 ) ); 239 $a2 = $this->factory->activity->create( array( 240 'content' => 'Life Drools', 241 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 242 ) ); 243 $a3 = bp_activity_new_comment( array( 244 'activity_id' => $a1, 245 'content' => 'Candy is good', 246 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 247 ) ); 248 249 global $activities_template; 250 bp_has_activities( 'display_comments=none' ); 251 $ids = wp_list_pluck( $activities_template->activities, 'id' ); 252 253 $this->assertEquals( array( $a1, $a2 ), $ids ); 254 255 } 256 /** 257 * @ticket BP5029 258 */ 259 public function test_get_with_display_comments_false_querystring() { 260 $now = time(); 261 $a1 = $this->factory->activity->create( array( 262 'content' => 'Life Rules', 263 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 264 ) ); 265 $a2 = $this->factory->activity->create( array( 266 'content' => 'Life Drools', 267 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 268 ) ); 269 $a3 = bp_activity_new_comment( array( 270 'activity_id' => $a1, 271 'content' => 'Candy is good', 272 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 273 ) ); 274 275 $expected = BP_Activity_Activity::get( array( 276 'display_comments' => false, 277 ) ); 278 279 $found = BP_Activity_Activity::get( 'display_comments=false' ); 280 $this->assertEquals( $expected, $found ); 281 282 } 283 284 140 285 }
Note: See TracChangeset
for help on using the changeset viewer.