WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/08/2019 12:55:20 AM (2 years ago)
Author:
pento
Message:

Coding Standards: Fix the remaining issues in /tests.

All PHP files in /tests now conform to the PHP coding standards, or have exceptions appropriately marked.

Travis now also runs phpcs on the /tests directory, any future changes to these files must conform entirely to the WordPress PHP coding standards. 🎉

See #47632.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/kses.php

    r45588 r45607  
    149149        foreach ( $bad as $k => $x ) {
    150150            $result = wp_kses_bad_protocol( wp_kses_normalize_entities( $x ), wp_allowed_protocols() );
    151             if ( ! empty( $result ) && $result != 'alert(1);' && $result != 'alert(1)' ) {
     151            if ( ! empty( $result ) && 'alert(1);' !== $result && 'alert(1)' !== $result ) {
    152152                switch ( $k ) {
    153153                    case 6:
     
    184184        foreach ( $safe as $x ) {
    185185            $result = wp_kses_bad_protocol( wp_kses_normalize_entities( $x ), array( 'http', 'https', 'dummy' ) );
    186             if ( $result != $x && $result != 'http://example.org/' ) {
     186            if ( $result !== $x && 'http://example.org/' !== $result ) {
    187187                $this->fail( "wp_kses_bad_protocol incorrectly blocked $x" );
    188188            }
     
    193193        $xss = simplexml_load_file( DIR_TESTDATA . '/formatting/xssAttacks.xml' );
    194194        foreach ( $xss->attack as $attack ) {
    195             if ( in_array( $attack->name, array( 'IMG Embedded commands 2', 'US-ASCII encoding', 'OBJECT w/Flash 2', 'Character Encoding Example' ) ) ) {
     195            if ( in_array( (string) $attack->name, array( 'IMG Embedded commands 2', 'US-ASCII encoding', 'OBJECT w/Flash 2', 'Character Encoding Example' ), true ) ) {
    196196                continue;
    197197            }
     
    199199            $code = (string) $attack->code;
    200200
    201             if ( $code == 'See Below' ) {
     201            if ( 'See Below' === $code ) {
    202202                continue;
    203203            }
    204204
    205             if ( substr( $code, 0, 4 ) == 'perl' ) {
     205            if ( substr( $code, 0, 4 ) === 'perl' ) {
    206206                $pos  = strpos( $code, '"' ) + 1;
    207207                $code = substr( $code, $pos, strrpos( $code, '"' ) - $pos );
     
    211211            $result = trim( wp_kses_data( $code ) );
    212212
    213             if ( $result == '' || $result == 'XSS' || $result == 'alert("XSS");' || $result == "alert('XSS');" ) {
     213            if ( in_array( $result, array( '', 'XSS', 'alert("XSS");', "alert('XSS');" ), true ) ) {
    214214                continue;
    215215            }
     
    325325
    326326    function _wp_kses_allowed_html_filter( $html, $context ) {
    327         if ( 'post' == $context ) {
     327        if ( 'post' === $context ) {
    328328            return array( 'a' => array( 'href' => true ) );
    329329        } else {
Note: See TracChangeset for help on using the changeset viewer.