WordPress.org

Make WordPress Core

Changeset 39919


Ignore:
Timestamp:
01/17/2017 03:39:36 AM (18 months ago)
Author:
SergeyBiryukov
Message:

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

Props peterwilsoncc.
Fixes #39219.

Location:
trunk/tests/phpunit
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase.php

    r39913 r39919  
    455455            $this->assertNotEmpty( $sub_array );
    456456        }
     457    }
     458
     459    /**
     460     * Asserts that a condition is not false.
     461     *
     462     * @param bool   $condition
     463     * @param string $message
     464     *
     465     * @throws PHPUnit_Framework_AssertionFailedError
     466     */
     467    public static function assertNotFalse( $condition, $message = '' ) {
     468        self::assertThat( $condition, self::logicalNot( self::isFalse() ), $message );
    457469    }
    458470
  • trunk/tests/phpunit/tests/customize/custom-css-setting.php

    r39918 r39919  
    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 ) );
  • trunk/tests/phpunit/tests/customize/setting.php

    r39318 r39919  
    457457        // Satisfy all requirements for save to happen.
    458458        wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    459         $this->assertTrue( false !== $setting->save() );
     459        $this->assertNotFalse( $setting->save() );
    460460        $this->assertTrue( 1 === did_action( 'customize_update_custom' ) );
    461461        $this->assertTrue( 1 === did_action( 'customize_save_foo' ) );
  • trunk/tests/phpunit/tests/media.php

    r39396 r39919  
    11761176        // Test to confirm all sources in the array include the same edit hash.
    11771177        foreach ( $sizes as $size ) {
    1178             $this->assertTrue( false !== strpos( $size, $hash ) );
     1178            $this->assertNotFalse( strpos( $size, $hash ) );
    11791179        }
    11801180    }
  • trunk/tests/phpunit/tests/oembed/template.php

    r36873 r39919  
    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
  • trunk/tests/phpunit/tests/oembed/wpOembed.php

    r37729 r39919  
    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    }
  • trunk/tests/phpunit/tests/post/thumbnails.php

    r38938 r39919  
    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 );
  • trunk/tests/phpunit/tests/post/wpPostType.php

    r38938 r39919  
    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    }
  • trunk/tests/phpunit/tests/term/wpTaxonomy.php

    r38747 r39919  
    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    }
  • trunk/tests/phpunit/tests/theme.php

    r39173 r39919  
    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
  • trunk/tests/phpunit/tests/theme/support.php

    r37313 r39919  
    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.