Make WordPress Core


Ignore:
Timestamp:
11/04/2021 03:22:47 PM (3 years ago)
Author:
hellofromTonya
Message:

Coding Standards: Add visibility to methods in tests/phpunit/tests/.

Adds a public visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a private visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a _ prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

File:
1 edited

Legend:

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

    r51623 r52010  
    99     * @ticket 23605
    1010     */
    11     function test_spaces() {
     11    public function test_spaces() {
    1212        $this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr WordPress' ) );
    1313        $this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr%20WordPress' ) );
     
    2020    }
    2121
    22     function test_bad_characters() {
     22    public function test_bad_characters() {
    2323        $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0Ago' ) );
    2424        $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0ago' ) );
     
    3434    }
    3535
    36     function test_relative() {
     36    public function test_relative() {
    3737        $this->assertSame( '/example.php', esc_url( '/example.php' ) );
    3838        $this->assertSame( 'example.php', esc_url( 'example.php' ) );
     
    4141    }
    4242
    43     function test_all_url_parts() {
     43    public function test_all_url_parts() {
    4444        $url = 'https://user:pass@host.example.com:1234/path;p=1?query=2&r[]=3#fragment';
    4545
     
    6161    }
    6262
    63     function test_bare() {
     63    public function test_bare() {
    6464        $this->assertSame( 'http://example.com?foo', esc_url( 'example.com?foo' ) );
    6565        $this->assertSame( 'http://example.com', esc_url( 'example.com' ) );
     
    6969    }
    7070
    71     function test_encoding() {
     71    public function test_encoding() {
    7272        $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
    7373        $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
     
    8282    }
    8383
    84     function test_protocol() {
     84    public function test_protocol() {
    8585        $this->assertSame( 'http://example.com', esc_url( 'http://example.com' ) );
    8686        $this->assertSame( '', esc_url( 'nasty://example.com/' ) );
     
    147147     * @ticket 23187
    148148     */
    149     function test_protocol_case() {
     149    public function test_protocol_case() {
    150150        $this->assertSame( 'http://example.com', esc_url( 'HTTP://example.com' ) );
    151151        $this->assertSame( 'http://example.com', esc_url( 'Http://example.com' ) );
    152152    }
    153153
    154     function test_display_extras() {
     154    public function test_display_extras() {
    155155        $this->assertSame( 'http://example.com/'quoted'', esc_url( 'http://example.com/\'quoted\'' ) );
    156156        $this->assertSame( 'http://example.com/\'quoted\'', esc_url( 'http://example.com/\'quoted\'', null, 'notdisplay' ) );
    157157    }
    158158
    159     function test_non_ascii() {
     159    public function test_non_ascii() {
    160160        $this->assertSame( 'http://example.org/баба', esc_url( 'http://example.org/баба' ) );
    161161        $this->assertSame( 'http://баба.org/баба', esc_url( 'http://баба.org/баба' ) );
     
    163163    }
    164164
    165     function test_feed() {
     165    public function test_feed() {
    166166        $this->assertSame( '', esc_url( 'feed:javascript:alert(1)' ) );
    167167        $this->assertSame( '', esc_url( 'feed:javascript:feed:alert(1)' ) );
     
    174174     * @ticket 16859
    175175     */
    176     function test_square_brackets() {
     176    public function test_square_brackets() {
    177177        $this->assertSame( '/example.php?one%5B%5D=two', esc_url( '/example.php?one[]=two' ) );
    178178        $this->assertSame( '?foo%5Bbar%5D=baz', esc_url( '?foo[bar]=baz' ) );
     
    189189     * Courtesy of http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding
    190190     */
    191     function test_reserved_characters() {
     191    public function test_reserved_characters() {
    192192        $url = "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$%27()*+,;=/?:@-._~!$%27()*+,;==#/?:@-._~!$&'()*+,;=";
    193193        $this->assertSame( $url, esc_url_raw( $url ) );
     
    197197     * @ticket 21974
    198198     */
    199     function test_protocol_relative_with_colon() {
     199    public function test_protocol_relative_with_colon() {
    200200        $this->assertSame( '//example.com/foo?foo=abc:def', esc_url( '//example.com/foo?foo=abc:def' ) );
    201201    }
     
    204204     * @ticket 31632
    205205     */
    206     function test_mailto_with_newline() {
     206    public function test_mailto_with_newline() {
    207207        $body       = <<<EOT
    208208Hi there,
     
    219219     * @ticket 31632
    220220     */
    221     function test_mailto_in_http_url_with_newline() {
     221    public function test_mailto_in_http_url_with_newline() {
    222222        $body       = <<<EOT
    223223Hi there,
     
    234234     * @ticket 23605
    235235     */
    236     function test_mailto_with_spaces() {
     236    public function test_mailto_with_spaces() {
    237237        $body = 'Hi there, I thought you might want to sign up for this newsletter';
    238238
     
    245245     * @ticket 28015
    246246     */
    247     function test_invalid_charaters() {
     247    public function test_invalid_charaters() {
    248248        $this->assertEmpty( esc_url_raw( '"^<>{}`' ) );
    249249    }
     
    252252     * @ticket 34202
    253253     */
    254     function test_ipv6_hosts() {
     254    public function test_ipv6_hosts() {
    255255        $this->assertSame( '//[::127.0.0.1]', esc_url( '//[::127.0.0.1]' ) );
    256256        $this->assertSame( 'http://[::FFFF::127.0.0.1]', esc_url( 'http://[::FFFF::127.0.0.1]' ) );
Note: See TracChangeset for help on using the changeset viewer.