Make WordPress Core


Ignore:
Timestamp:
06/23/2022 08:27:34 PM (3 years ago)
Author:
azaozz
Message:

Build/Test Tools, Formatting group:

  • Add and update @covers tags.
  • Add and improve docs and inline comments.

Props pbeane, hellofromTonya, antonvlasenko, ironprogrammer, SergeyBiryukov, costdev.
See #39265.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/escUrl.php

    r53455 r53562  
    88    /**
    99     * @ticket 23605
     10     *
     11     * @covers ::esc_url
    1012     */
    1113    public function test_spaces() {
     
    2022    }
    2123
     24    /**
     25     * @covers ::esc_url
     26     */
    2227    public function test_bad_characters() {
    2328        $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0Ago' ) );
     
    3439    }
    3540
     41    /**
     42     * @covers ::esc_url
     43     */
    3644    public function test_relative() {
    3745        $this->assertSame( '/example.php', esc_url( '/example.php' ) );
     
    4149    }
    4250
     51    /**
     52     * @covers ::esc_url
     53     * @covers ::esc_url_raw
     54     */
    4355    public function test_all_url_parts() {
    4456        $url = 'https://user:pass@host.example.com:1234/path;p=1?query=2&r[]=3#fragment';
     
    5769            parse_url( $url )
    5870        );
    59         $this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', sanitize_url( $url ) );
     71        $this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url_raw( $url ) );
    6072        $this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url( $url ) );
    6173    }
    6274
     75    /**
     76     * @covers ::esc_url
     77     */
    6378    public function test_bare() {
    6479        $this->assertSame( 'http://example.com?foo', esc_url( 'example.com?foo' ) );
     
    6984    }
    7085
     86    /**
     87     * @covers ::esc_url
     88     * @covers ::esc_url_raw
     89     */
    7190    public function test_encoding() {
    72         $this->assertSame( 'http://example.com?foo=1&bar=2', sanitize_url( 'http://example.com?foo=1&bar=2' ) );
    73         $this->assertSame( 'http://example.com?foo=1&bar=2', sanitize_url( 'http://example.com?foo=1&bar=2' ) );
    74         $this->assertSame( 'http://example.com?foo=1&bar=2', sanitize_url( 'http://example.com?foo=1&bar=2' ) );
     91        $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
     92        $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
     93        $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
    7594
    7695        $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) );
     
    82101    }
    83102
     103    /**
     104     * @covers ::esc_url
     105     * @covers ::wp_allowed_protocols
     106     */
    84107    public function test_protocol() {
    85108        $this->assertSame( 'http://example.com', esc_url( 'http://example.com' ) );
     
    146169    /**
    147170     * @ticket 23187
     171     *
     172     * @covers ::esc_url
    148173     */
    149174    public function test_protocol_case() {
     
    152177    }
    153178
     179    /**
     180     * @covers ::esc_url
     181     */
    154182    public function test_display_extras() {
    155183        $this->assertSame( 'http://example.com/'quoted'', esc_url( 'http://example.com/\'quoted\'' ) );
     
    157185    }
    158186
     187    /**
     188     * @covers ::esc_url
     189     */
    159190    public function test_non_ascii() {
    160191        $this->assertSame( 'http://example.org/баба', esc_url( 'http://example.org/баба' ) );
     
    163194    }
    164195
     196    /**
     197     * @covers ::esc_url
     198     */
    165199    public function test_feed() {
    166200        $this->assertSame( '', esc_url( 'feed:javascript:alert(1)' ) );
     
    173207    /**
    174208     * @ticket 16859
     209     *
     210     * @covers ::esc_url
    175211     */
    176212    public function test_square_brackets() {
     
    188224    /**
    189225     * Courtesy of http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding
     226     *
     227     * @covers ::esc_url_raw
    190228     */
    191229    public function test_reserved_characters() {
    192230        $url = "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$%27()*+,;=/?:@-._~!$%27()*+,;==#/?:@-._~!$&'()*+,;=";
    193         $this->assertSame( $url, sanitize_url( $url ) );
     231        $this->assertSame( $url, esc_url_raw( $url ) );
    194232    }
    195233
    196234    /**
    197235     * @ticket 21974
     236     *
     237     * @covers ::esc_url
    198238     */
    199239    public function test_protocol_relative_with_colon() {
     
    203243    /**
    204244     * @ticket 31632
     245     *
     246     * @covers ::esc_url
    205247     */
    206248    public function test_mailto_with_newline() {
     
    218260    /**
    219261     * @ticket 31632
     262     *
     263     * @covers ::esc_url
    220264     */
    221265    public function test_mailto_in_http_url_with_newline() {
     
    233277    /**
    234278     * @ticket 23605
     279     *
     280     * @covers ::esc_url
    235281     */
    236282    public function test_mailto_with_spaces() {
     
    244290    /**
    245291     * @ticket 28015
     292     *
     293     * @covers ::esc_url_raw
    246294     */
    247295    public function test_invalid_charaters() {
    248         $this->assertEmpty( sanitize_url( '"^<>{}`' ) );
     296        $this->assertEmpty( esc_url_raw( '"^<>{}`' ) );
    249297    }
    250298
    251299    /**
    252300     * @ticket 34202
     301     *
     302     * @covers ::esc_url
    253303     */
    254304    public function test_ipv6_hosts() {
Note: See TracChangeset for help on using the changeset viewer.