Make WordPress Core

Ticket #17780: specialchars-tests.diff

File specialchars-tests.diff, 2.3 KB (added by miqrogroove, 11 years ago)
  • tests/phpunit/tests/formatting/WPSpecialchars.php

     
    3939                $this->assertEquals( '"'hello!'"', _wp_specialchars($source, true) );
    4040                $this->assertEquals( $source, _wp_specialchars($source) );
    4141        }
     42
     43        /**
     44         * Check some of the double-encoding features for entity references.
     45         *
     46         * @ticket 17780
     47         * @dataProvider data_double_encoding
     48         */
     49        function test_double_encoding( $input, $output ) {
     50                return $this->assertEquals( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, true ) );
     51        }
     52
     53        function data_double_encoding() {
     54                return array(
     55                        array(
     56                                'This & that, this & that, — " " Ú   " " " " " $ ×',
     57                                'This & that, this & that, — " " Ú   " " " " " $ ×',
     58                        ),
     59                        array(
     60                                '&& && && &;',
     61                                '&& && && &;',
     62                        ),
     63                        array(
     64                                '&garbage; &***; &aaaa; &0000; &####; &;;',
     65                                '&garbage; &***; &aaaa; &0000; &####; &;;',
     66                        ),
     67                );
     68        }
     69
     70        /**
     71         * Check some of the double-encoding features for entity references.
     72         *
     73         * @ticket 17780
     74         * @dataProvider data_no_double_encoding
     75         */
     76        function test_no_double_encoding( $input, $output ) {
     77                return $this->assertEquals( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, false ) );
     78        }
     79
     80        function data_no_double_encoding() {
     81                return array(
     82                        array(
     83                                'This & that, this & that, — " " Ú   " " " " " $ ×',
     84                                'This & that, this & that, — " " Ú   " " " " " $ ×',
     85                        ),
     86                        array(
     87                                '&& && && &;',
     88                                '&& && && &;',
     89                        ),
     90                        array(
     91                                '&garbage; &***; &aaaa; &0000; &####; &;;',
     92                                '&garbage; &***; &aaaa; &0000; &####; &;;',
     93                        ),
     94                );
     95        }
    4296}