Make WordPress Core

Changeset 33855


Ignore:
Timestamp:
09/02/2015 04:50:02 PM (9 years ago)
Author:
johnbillion
Message:

More unit tests for esc_url() and esc_url_raw().

See #23605, #20771, #16859

File:
1 edited

Legend:

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

    r33851 r33855  
    3131    }
    3232
     33    function test_all_url_parts() {
     34        $url = 'https://user:password@host.example.com:1234/path;p=1?q=2&r=3#fragment';
     35        $this->assertEquals( $url, esc_url_raw( $url ) );
     36
     37        $this->assertEquals( 'https://user:password@host.example.com:1234/path;p=1?q=2&r=3#fragment', esc_url( $url ) );
     38
     39        $this->assertEquals( 'http://example.com?foo', esc_url( 'http://example.com?foo' ) );
     40    }
     41
    3342    function test_bare() {
    3443        $this->assertEquals( 'http://example.com', esc_url( 'example.com' ) );
     
    3948
    4049    function test_encoding() {
     50        $this->assertEquals( 'http://example.com?foo=1&bar=2',      esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
     51        $this->assertEquals( 'http://example.com?foo=1&bar=2',  esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
     52        $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
     53
    4154        $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) );
    4255        $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) );
    4356        $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) );
     57
     58        $param = urlencode( 'http://example.com/?one=1&two=2' );
     59        $this->assertEquals( "http://example.com?url={$param}", esc_url( "http://example.com?url={$param}" ) );
    4460    }
    4561
Note: See TracChangeset for help on using the changeset viewer.