Make WordPress Core

Changeset 40388


Ignore:
Timestamp:
04/06/2017 06:19:02 PM (7 years ago)
Author:
swissspidy
Message:

Build/Test Tools: Add assertNotFalse() method to WP_UnitTestCase and use it where appropriate.

Props peterwilsoncc.
Fixes #39219.

Merges [39919] to the 4.7 branch.

Location:
branches/4.7
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/tests/phpunit/includes/testcase.php

    r40250 r40388  
    459459        ksort( $actual );
    460460        $this->assertEquals( $expected, $actual );
     461    }
     462
     463    /**
     464     * Asserts that a condition is not false.
     465     *
     466     * @param bool   $condition
     467     * @param string $message
     468     *
     469     * @throws PHPUnit_Framework_AssertionFailedError
     470     */
     471    public static function assertNotFalse( $condition, $message = '' ) {
     472        self::assertThat( $condition, self::logicalNot( self::isFalse() ), $message );
    461473    }
    462474
  • branches/4.7/tests/phpunit/tests/customize/custom-css-setting.php

    r39694 r40388  
    151151        $saved = $this->setting->save();
    152152
    153         $this->assertTrue( false !== $saved );
     153        $this->assertNotFalse( $saved );
    154154        $this->assertEquals( $updated_css, $this->setting->value() );
    155155        $this->assertEquals( $updated_css, wp_get_custom_css( $this->setting->stylesheet ) );
  • branches/4.7/tests/phpunit/tests/customize/setting.php

    r40088 r40388  
    466466        // Satisfy all requirements for save to happen.
    467467        wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    468         $this->assertTrue( false !== $setting->save() );
     468        $this->assertNotFalse( $setting->save() );
    469469        $this->assertTrue( 1 === did_action( 'customize_update_custom' ) );
    470470        $this->assertTrue( 1 === did_action( 'customize_save_foo' ) );
  • branches/4.7/tests/phpunit/tests/media.php

    r40071 r40388  
    12591259        // Test to confirm all sources in the array include the same edit hash.
    12601260        foreach ( $sizes as $size ) {
    1261             $this->assertTrue( false !== strpos( $size, $hash ) );
     1261            $this->assertNotFalse( strpos( $size, $hash ) );
    12621262        }
    12631263    }
  • branches/4.7/tests/phpunit/tests/oembed/template.php

    r36873 r40388  
    2626        $doc = new DOMDocument();
    2727        $this->assertTrue( $doc->loadHTML( $actual ) );
    28         $this->assertTrue( false === strpos( $actual, 'That embed can’t be found.' ) );
    29         $this->assertTrue( false !== strpos( $actual, 'Hello World' ) );
     28        $this->assertFalse( strpos( $actual, 'That embed can’t be found.' ) );
     29        $this->assertNotFalse( strpos( $actual, 'Hello World' ) );
    3030    }
    3131
     
    5353        $this->assertTrue( $doc->loadHTML( $actual ) );
    5454        $this->assertFalse( strpos( $actual, 'That embed can’t be found.' ) );
    55         $this->assertTrue( false !== strpos( $actual, 'Hello World' ) );
    56         $this->assertTrue( false !== strpos( $actual, 'canola.jpg' ) );
     55        $this->assertNotFalse( strpos( $actual, 'Hello World' ) );
     56        $this->assertNotFalse( strpos( $actual, 'canola.jpg' ) );
    5757    }
    5858
     
    6969        $doc = new DOMDocument();
    7070        $this->assertTrue( $doc->loadHTML( $actual ) );
    71         $this->assertTrue( false !== strpos( $actual, 'That embed can’t be found.' ) );
     71        $this->assertNotFalse( strpos( $actual, 'That embed can’t be found.' ) );
    7272    }
    7373
     
    9393        $this->assertTrue( $doc->loadHTML( $actual ) );
    9494        $this->assertFalse( strpos( $actual, 'That embed can’t be found.' ) );
    95         $this->assertTrue( false !== strpos( $actual, 'Hello World' ) );
    96         $this->assertTrue( false !== strpos( $actual, 'canola.jpg' ) );
     95        $this->assertNotFalse( strpos( $actual, 'Hello World' ) );
     96        $this->assertNotFalse( strpos( $actual, 'canola.jpg' ) );
    9797    }
    9898
     
    115115        $doc = new DOMDocument();
    116116        $this->assertTrue( $doc->loadHTML( $actual ) );
    117         $this->assertTrue( false !== strpos( $actual, 'That embed can’t be found.' ) );
     117        $this->assertNotFalse( strpos( $actual, 'That embed can’t be found.' ) );
    118118    }
    119119
     
    137137        $doc = new DOMDocument();
    138138        $this->assertTrue( $doc->loadHTML( $actual ) );
    139         $this->assertTrue( false !== strpos( $actual, 'That embed can’t be found.' ) );
     139        $this->assertNotFalse( strpos( $actual, 'That embed can’t be found.' ) );
    140140    }
    141141
     
    158158        $doc = new DOMDocument();
    159159        $this->assertTrue( $doc->loadHTML( $actual ) );
    160         $this->assertTrue( false !== strpos( $actual, 'That embed can’t be found.' ) );
     160        $this->assertNotFalse( strpos( $actual, 'That embed can’t be found.' ) );
    161161    }
    162162
     
    183183        $doc = new DOMDocument();
    184184        $this->assertTrue( $doc->loadHTML( $actual ) );
    185         $this->assertTrue( false === strpos( $actual, 'That embed can’t be found.' ) );
    186         $this->assertTrue( false !== strpos( $actual, 'Hello World' ) );
     185        $this->assertFalse( strpos( $actual, 'That embed can’t be found.' ) );
     186        $this->assertNotFalse( strpos( $actual, 'Hello World' ) );
    187187    }
    188188
  • branches/4.7/tests/phpunit/tests/oembed/wpOembed.php

    r37729 r40388  
    3737        remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
    3838
    39         $this->assertTrue( false !== $this->pre_oembed_result_filtered );
     39        $this->assertNotFalse( $this->pre_oembed_result_filtered );
    4040        $this->assertEquals( $this->pre_oembed_result_filtered, $actual );
    4141    }
     
    5252        remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
    5353
    54         $this->assertTrue( false !== $this->pre_oembed_result_filtered );
     54        $this->assertNotFalse( $this->pre_oembed_result_filtered );
    5555        $this->assertEquals( $this->pre_oembed_result_filtered, $actual );
    5656    }
     
    6767        remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
    6868
    69         $this->assertTrue( false !== $this->pre_oembed_result_filtered );
     69        $this->assertNotFalse( $this->pre_oembed_result_filtered );
    7070        $this->assertFalse( $actual );
    7171    }
  • branches/4.7/tests/phpunit/tests/post/thumbnails.php

    r38938 r40388  
    195195        set_post_thumbnail( self::$post, self::$attachment_id );
    196196
    197         $this->assertTrue( false !== get_the_post_thumbnail_url( self::$post->ID ) );
     197        $this->assertNotFalse( get_the_post_thumbnail_url( self::$post->ID ) );
    198198
    199199        $deleted = wp_delete_post( self::$post->ID, true );
  • branches/4.7/tests/phpunit/tests/post/wpPostType.php

    r38938 r40388  
    102102        $rewrite_tags_after = $wp_rewrite->rewritecode;
    103103
    104         $this->assertTrue( false !== array_search( "%$post_type%", $rewrite_tags ) );
     104        $this->assertNotFalse( array_search( "%$post_type%", $rewrite_tags ) );
    105105        $this->assertFalse( array_search( "%$post_type%", $rewrite_tags_after ) );
    106106    }
  • branches/4.7/tests/phpunit/tests/term/wpTaxonomy.php

    r38747 r40388  
    6767        $rewrite_tags_after = $wp_rewrite->rewritecode;
    6868
    69         $this->assertTrue( false !== array_search( "%$taxonomy%", $rewrite_tags ) );
     69        $this->assertNotFalse( array_search( "%$taxonomy%", $rewrite_tags ) );
    7070        $this->assertFalse( array_search( "%$taxonomy%", $rewrite_tags_after ) );
    7171    }
  • branches/4.7/tests/phpunit/tests/theme.php

    r39173 r40388  
    303303        $theme = wp_get_theme();
    304304        $this->assertEquals( $style, (string) $theme );
    305         $this->assertNotSame( false, $theme->errors() );
     305        $this->assertNotFalse( $theme->errors() );
    306306        $this->assertFalse( $theme->exists() );
    307307
  • branches/4.7/tests/phpunit/tests/theme/support.php

    r37313 r40388  
    9191        $this->assertFalse( current_theme_supports( 'html5' ) );
    9292        $this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) );
    93         $this->assertNotSame( false, add_theme_support( 'html5' ) );
     93        $this->assertNotFalse( add_theme_support( 'html5' ) );
    9494        $this->assertTrue( current_theme_supports( 'html5' ) );
    9595        $this->assertTrue( current_theme_supports( 'html5', 'comment-form' ) );
     
    109109        $this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) );
    110110        $this->assertFalse( add_theme_support( 'html5', 'comment-form' ) );
    111         $this->assertNotSame( false, add_theme_support( 'html5', array( 'comment-form' ) ) );
     111        $this->assertNotFalse( add_theme_support( 'html5', array( 'comment-form' ) ) );
    112112        $this->assertTrue( current_theme_supports( 'html5', 'comment-form' ) );
    113113
     
    118118        // It appends, rather than replaces.
    119119        $this->assertFalse( current_theme_supports( 'html5', 'comment-list' ) );
    120         $this->assertNotSame( false, add_theme_support( 'html5', array( 'comment-list' ) ) );
     120        $this->assertNotFalse( add_theme_support( 'html5', array( 'comment-list' ) ) );
    121121        $this->assertTrue( current_theme_supports( 'html5', 'comment-form' ) );
    122122        $this->assertTrue( current_theme_supports( 'html5', 'comment-list' ) );
Note: See TracChangeset for help on using the changeset viewer.