| | 1 | <?php |
| | 2 | |
| | 3 | |
| | 4 | /** |
| | 5 | * @group wp-includes/load.php |
| | 6 | */ |
| | 7 | class Tests_Load extends WP_UnitTestCase { |
| | 8 | |
| | 9 | function tearDown() { |
| | 10 | unset( $_GET['ticket_19455'] ); |
| | 11 | unset( $_POST['ticket_19455'] ); |
| | 12 | unset( $_COOKIE['ticket_19455'] ); |
| | 13 | parent::tearDown(); |
| | 14 | } |
| | 15 | |
| | 16 | |
| | 17 | public function strings_and_expected_strings() { |
| | 18 | return array( |
| | 19 | array( 'A string with no quotes', 'A string with no quotes' ), |
| | 20 | array( "Charlie's Little Cat", "Charlie\\'s Little Cat" ), |
| | 21 | array( "A string with many quotes''''''", "A string with many quotes\\'\\'\\'\\'\\'\\'" ), |
| | 22 | array( |
| | 23 | "A string with quotes ' in '' different ''' places''''", |
| | 24 | "A string with quotes \\' in \\'\\' different \\'\\'\\' places\\'\\'\\'\\'" |
| | 25 | ), |
| | 26 | array( "A string with 'quoted' words", "A string with \\'quoted\\' words" ), |
| | 27 | ); |
| | 28 | } |
| | 29 | |
| | 30 | /** |
| | 31 | * String in $_GET array is modified as expected |
| | 32 | * |
| | 33 | * @dataProvider strings_and_expected_strings |
| | 34 | */ |
| | 35 | public function test_string_in_GET_array_is_modified_as_expected( $original, $expected ) { |
| | 36 | $_GET['ticket_19455'] = $original; |
| | 37 | |
| | 38 | wp_magic_quotes(); |
| | 39 | |
| | 40 | $this->assertEquals( $expected, $_GET['ticket_19455'] ); |
| | 41 | } |
| | 42 | |
| | 43 | /** |
| | 44 | * String in $_POST array is modified as expected |
| | 45 | * |
| | 46 | * @dataProvider strings_and_expected_strings |
| | 47 | */ |
| | 48 | public function test_string_in_POST_array_is_modified_as_expected( $original, $expected ) { |
| | 49 | $_POST['ticket_19455'] = $original; |
| | 50 | |
| | 51 | wp_magic_quotes(); |
| | 52 | |
| | 53 | $this->assertEquals( $expected, $_POST['ticket_19455'] ); |
| | 54 | } |
| | 55 | |
| | 56 | /** |
| | 57 | * String in $_COOKIE array is modified as expected |
| | 58 | * |
| | 59 | * @dataProvider strings_and_expected_strings |
| | 60 | */ |
| | 61 | public function test_string_in_COOKIE_array_is_modified_as_expected( $original, $expected ) { |
| | 62 | $_COOKIE['ticket_19455'] = $original; |
| | 63 | |
| | 64 | wp_magic_quotes(); |
| | 65 | |
| | 66 | $this->assertEquals( $expected, $_COOKIE['ticket_19455'] ); |
| | 67 | } |
| | 68 | |
| | 69 | } |