Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r33271 r42343  
    66class Tests_Formatting_JSEscape extends WP_UnitTestCase {
    77    function test_js_escape_simple() {
    8         $out = esc_js('foo bar baz();');
    9         $this->assertEquals('foo bar baz();', $out);
     8        $out = esc_js( 'foo bar baz();' );
     9        $this->assertEquals( 'foo bar baz();', $out );
    1010    }
    1111
    1212    function test_js_escape_quotes() {
    13         $out = esc_js('foo "bar" \'baz\'');
     13        $out = esc_js( 'foo "bar" \'baz\'' );
    1414        // does it make any sense to change " into "?  Why not \"?
    15         $this->assertEquals("foo "bar" \'baz\'", $out);
     15        $this->assertEquals( "foo "bar" \'baz\'", $out );
    1616    }
    1717
    1818    function test_js_escape_backslash() {
    19         $bs = '\\';
    20         $out = esc_js('foo '.$bs.'t bar '.$bs.$bs.' baz');
     19        $bs  = '\\';
     20        $out = esc_js( 'foo ' . $bs . 't bar ' . $bs . $bs . ' baz' );
    2121        // \t becomes t - bug?
    22         $this->assertEquals('foo t bar '.$bs.$bs.' baz', $out);
     22        $this->assertEquals( 'foo t bar ' . $bs . $bs . ' baz', $out );
    2323    }
    2424
    2525    function test_js_escape_amp() {
    26         $out = esc_js('foo & bar &baz;  ');
    27         $this->assertEquals("foo & bar &baz;  ", $out);
     26        $out = esc_js( 'foo & bar &baz;  ' );
     27        $this->assertEquals( 'foo & bar &baz;  ', $out );
    2828    }
    2929
    3030    function test_js_escape_quote_entity() {
    31         $out = esc_js('foo ' bar ' baz &');
    32         $this->assertEquals("foo \\' bar \\' baz &", $out);
     31        $out = esc_js( 'foo ' bar ' baz &' );
     32        $this->assertEquals( "foo \\' bar \\' baz &", $out );
    3333    }
    3434
    3535    function test_js_no_carriage_return() {
    36         $out = esc_js("foo\rbar\nbaz\r");
     36        $out = esc_js( "foo\rbar\nbaz\r" );
    3737        // \r is stripped
    38         $this->assertequals("foobar\\nbaz", $out);
     38        $this->assertequals( "foobar\\nbaz", $out );
    3939    }
    4040
    4141    function test_js_escape_rn() {
    42         $out = esc_js("foo\r\nbar\nbaz\r\n");
     42        $out = esc_js( "foo\r\nbar\nbaz\r\n" );
    4343        // \r is stripped
    44         $this->assertequals("foo\\nbar\\nbaz\\n", $out);
     44        $this->assertequals( "foo\\nbar\\nbaz\\n", $out );
    4545    }
    4646}
Note: See TracChangeset for help on using the changeset viewer.