- Timestamp:
- 05/29/2013 12:34:35 AM (11 years ago)
- File:
-
- 1 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 */
Note: See TracChangeset
for help on using the changeset viewer.