Changeset 9415
- Timestamp:
- 01/29/2015 04:33:39 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-template.php
r9386 r9415 140 140 141 141 $r = wp_parse_args( $args, array( 142 'page' => 1, 143 'per_page' => 10, 144 'page_arg' => 'mpage', 145 'box' => 'inbox', 146 'type' => 'all', 142 147 'user_id' => bp_loggedin_user_id(), 143 'box' => 'inbox',144 'per_page' => 10,145 148 'max' => false, 146 'type' => 'all',147 149 'search_terms' => '', 148 'page_arg' => 'mpage',149 150 'meta_query' => array(), 150 151 ) ); 151 152 152 $this->pag_ page = isset( $_GET[ $r['page_arg'] ] ) ? intval( $_GET[ $r['page_arg'] ] ) : 1;153 $this->pag_ num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $r['per_page'];154 153 $this->pag_arg = sanitize_key( $r['page_arg'] ); 154 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] ); 155 $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] ); 155 156 $this->user_id = $r['user_id']; 156 157 $this->box = $r['box']; -
trunk/tests/phpunit/testcases/messages/template.php
r9335 r9415 258 258 $this->assertEqualSets( array( $t1 ), wp_list_pluck( $messages_template->threads, 'thread_id' ) ); 259 259 } 260 261 /** 262 * @group BP_Messages_Box_Template 263 */ 264 public function test_bp_messages_template_should_give_precedence_to_mpage_URL_param() { 265 $request = $_REQUEST; 266 $_REQUEST['mpage'] = '5'; 267 268 $at = new BP_Messages_Box_Template( array( 269 'page' => 8, 270 ) ); 271 272 $this->assertEquals( 5, $at->pag_page ); 273 274 $_REQUEST = $request; 275 } 276 277 /** 278 * @group BP_Messages_Box_Template 279 */ 280 public function test_bp_messages_template_should_reset_0_pag_page_URL_param_to_default_pag_page_value() { 281 $request = $_REQUEST; 282 $_REQUEST['mpage'] = '0'; 283 284 $at = new BP_Messages_Box_Template( array( 285 'page' => 8, 286 ) ); 287 288 $this->assertEquals( 8, $at->pag_page ); 289 290 $_REQUEST = $request; 291 } 292 293 /** 294 * @group BP_Messages_Box_Template 295 */ 296 public function test_bp_messages_template_should_give_precedence_to_num_URL_param() { 297 $request = $_REQUEST; 298 $_REQUEST['num'] = '14'; 299 300 $at = new BP_Messages_Box_Template( array( 301 'per_page' => 13, 302 ) ); 303 304 $this->assertEquals( 14, $at->pag_num ); 305 306 $_REQUEST = $request; 307 } 308 309 /** 310 * @group BP_Messages_Box_Template 311 */ 312 public function test_bp_messages_template_should_reset_0_pag_num_URL_param_to_default_pag_num_value() { 313 $request = $_REQUEST; 314 $_REQUEST['num'] = '0'; 315 316 $at = new BP_Messages_Box_Template( array( 317 'per_page' => 13, 318 ) ); 319 320 $this->assertEquals( 13, $at->pag_num ); 321 322 $_REQUEST = $request; 323 } 260 324 }
Note: See TracChangeset
for help on using the changeset viewer.