| | 149 | function test_bp_has_activities_just_me_scope_with_no_user_id() { |
| | 150 | $u1 = $this->factory->user->create(); |
| | 151 | $u2 = $this->factory->user->create(); |
| | 152 | |
| | 153 | // save the current user and override logged-in user |
| | 154 | $old_user = get_current_user_id(); |
| | 155 | $this->set_current_user( $u1 ); |
| | 156 | |
| | 157 | $now = time(); |
| | 158 | |
| | 159 | // activity item |
| | 160 | $a1 = $this->factory->activity->create( array( |
| | 161 | 'user_id' => $u1, |
| | 162 | 'component' => 'activity', |
| | 163 | 'type' => 'activity_update', |
| | 164 | 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), |
| | 165 | ) ); |
| | 166 | |
| | 167 | // misc activity items |
| | 168 | |
| | 169 | $this->factory->activity->create( array( |
| | 170 | 'user_id' => $u2, |
| | 171 | 'component' => 'activity', |
| | 172 | 'type' => 'activity_update', |
| | 173 | 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), |
| | 174 | ) ); |
| | 175 | $this->factory->activity->create( array( |
| | 176 | 'user_id' => $u2, |
| | 177 | 'component' => 'groups', |
| | 178 | 'item_id' => 324, |
| | 179 | 'type' => 'activity_update', |
| | 180 | 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), |
| | 181 | ) ); |
| | 182 | |
| | 183 | global $activities_template; |
| | 184 | |
| | 185 | // grab just-me scope with no user ID |
| | 186 | // user ID should fallback to logged-in user ID |
| | 187 | bp_has_activities( array( |
| | 188 | 'user_id' => false, |
| | 189 | 'scope' => 'just-me', |
| | 190 | ) ); |
| | 191 | |
| | 192 | // assert! |
| | 193 | $this->assertEqualSets( array( $a1 ), wp_list_pluck( $activities_template->activities, 'id' ) ); |
| | 194 | |
| | 195 | // clean up! |
| | 196 | $activities_template = null; |
| | 197 | $this->set_current_user( $old_user ); |
| | 198 | } |
| | 199 | |
| | 200 | /** |
| | 201 | * @group scope |
| | 202 | * @group filter_query |
| | 203 | * @group BP_Activity_Query |
| | 204 | */ |