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