Make WordPress Core

Ticket #52458: 52458.test.diff

File 52458.test.diff, 1.1 KB (added by SergeyBiryukov, 3 years ago)
  • tests/phpunit/tests/formatting/escUrl.php

     
    262262                $this->assertSame( 'http://[::FFFF::127.0.0.1]/?foo%5Bbar%5D=baz', esc_url( 'http://[::FFFF::127.0.0.1]/?foo[bar]=baz' ) );
    263263        }
    264264
     265        /**
     266         * Test escaping of non-string values.
     267         *
     268         * @ticket 52458
     269         * @dataProvider data_non_string_values
     270         *
     271         * @param mixed $value    The value to be escaped.
     272         * @param mixed $expected The expected escaped value.
     273         */
     274        function test_non_string_values( $value, $expected ) {
     275                $this->assertSame( $expected, esc_url( $value ) );
     276        }
     277
     278        /**
     279         * Data provider for `test_non_string_values()`.
     280         *
     281         * @return array {
     282         *     @type mixed $value    The value to be escaped.
     283         *     @type mixed $expected The expected escaped value.
     284         * }
     285         */
     286        function data_non_string_values() {
     287                return array(
     288                        array( true, 'http://1' ),
     289                        array( false, '' ),
     290                        array( null, '' ),
     291                        array( 0, 'http://0' ),
     292                        array( 1, 'http://1' ),
     293                );
     294        }
     295
    265296}