Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/29/2015 03:36:16 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Introduce bp_sanitize_pagination_arg() and related tests. This function will help sanitize our pagination request values, as they are frequently accessed via globally accessible variables for ajax requests. See #5796.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/functions.php

    r9295 r9410  
    393393
    394394        $this->assertEquals( $expected, bp_alpha_sort_by_key( $items, 'name' ) );
     395    }
     396
     397    /**
     398     * @group bp_sanitize_pagination_arg
     399     */
     400    public function test_bp_sanitize_pagination_arg_zero() {
     401        $request          = $_REQUEST;
     402        $arg              = 'bp_pagination_test';
     403        $page             = 1;
     404        $_REQUEST[ $arg ] = '0';
     405        $value            = bp_sanitize_pagination_arg( $arg, $page );
     406
     407        $this->assertEquals( $value, $page );
     408
     409        $_REQUEST = $request;
     410    }
     411
     412    /**
     413     * @group bp_sanitize_pagination_arg
     414     */
     415    public function test_bp_sanitize_pagination_arg_negative() {
     416        $request          = $_REQUEST;
     417        $arg              = 'bp_pagination_test';
     418        $page             = 25;
     419        $_REQUEST[ $arg ] = '-25';
     420        $value            = bp_sanitize_pagination_arg( $arg, $page );
     421
     422        $this->assertEquals( $value, $page );
     423
     424        $_REQUEST = $request;
    395425    }
    396426
Note: See TracChangeset for help on using the changeset viewer.