Build/Test Tools: Add assertNotFalse()
method to WP_UnitTestCase
and use it where appropriate.
Props peterwilsoncc. Fixes #39219. git-svn-id: https://develop.svn.wordpress.org/trunk@39919 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
550818ac31
commit
97a4d6c16d
@ -456,6 +456,18 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a condition is not false.
|
||||
*
|
||||
* @param bool $condition
|
||||
* @param string $message
|
||||
*
|
||||
* @throws PHPUnit_Framework_AssertionFailedError
|
||||
*/
|
||||
public static function assertNotFalse( $condition, $message = '' ) {
|
||||
self::assertThat( $condition, self::logicalNot( self::isFalse() ), $message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify WordPress's query internals as if a given URL has been requested.
|
||||
*
|
||||
|
@ -150,7 +150,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
|
||||
$this->wp_customize->set_post_value( $this->setting->id, $updated_css );
|
||||
$saved = $this->setting->save();
|
||||
|
||||
$this->assertTrue( false !== $saved );
|
||||
$this->assertNotFalse( $saved );
|
||||
$this->assertEquals( $updated_css, $this->setting->value() );
|
||||
$this->assertEquals( $updated_css, wp_get_custom_css( $this->setting->stylesheet ) );
|
||||
$this->assertEquals( $updated_css, get_post( $post_id )->post_content );
|
||||
|
@ -456,7 +456,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
|
||||
// Satisfy all requirements for save to happen.
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$this->assertTrue( false !== $setting->save() );
|
||||
$this->assertNotFalse( $setting->save() );
|
||||
$this->assertTrue( 1 === did_action( 'customize_update_custom' ) );
|
||||
$this->assertTrue( 1 === did_action( 'customize_save_foo' ) );
|
||||
}
|
||||
|
@ -1175,7 +1175,7 @@ EOF;
|
||||
|
||||
// Test to confirm all sources in the array include the same edit hash.
|
||||
foreach ( $sizes as $size ) {
|
||||
$this->assertTrue( false !== strpos( $size, $hash ) );
|
||||
$this->assertNotFalse( strpos( $size, $hash ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ class Tests_Embed_Template extends WP_UnitTestCase {
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$this->assertTrue( $doc->loadHTML( $actual ) );
|
||||
$this->assertTrue( false === strpos( $actual, 'That embed can’t be found.' ) );
|
||||
$this->assertTrue( false !== strpos( $actual, 'Hello World' ) );
|
||||
$this->assertFalse( strpos( $actual, 'That embed can’t be found.' ) );
|
||||
$this->assertNotFalse( strpos( $actual, 'Hello World' ) );
|
||||
}
|
||||
|
||||
function test_oembed_output_post_with_thumbnail() {
|
||||
@ -52,8 +52,8 @@ class Tests_Embed_Template extends WP_UnitTestCase {
|
||||
$doc = new DOMDocument();
|
||||
$this->assertTrue( $doc->loadHTML( $actual ) );
|
||||
$this->assertFalse( strpos( $actual, 'That embed can’t be found.' ) );
|
||||
$this->assertTrue( false !== strpos( $actual, 'Hello World' ) );
|
||||
$this->assertTrue( false !== strpos( $actual, 'canola.jpg' ) );
|
||||
$this->assertNotFalse( strpos( $actual, 'Hello World' ) );
|
||||
$this->assertNotFalse( strpos( $actual, 'canola.jpg' ) );
|
||||
}
|
||||
|
||||
function test_oembed_output_404() {
|
||||
@ -68,7 +68,7 @@ class Tests_Embed_Template extends WP_UnitTestCase {
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$this->assertTrue( $doc->loadHTML( $actual ) );
|
||||
$this->assertTrue( false !== strpos( $actual, 'That embed can’t be found.' ) );
|
||||
$this->assertNotFalse( strpos( $actual, 'That embed can’t be found.' ) );
|
||||
}
|
||||
|
||||
function test_oembed_output_attachment() {
|
||||
@ -92,8 +92,8 @@ class Tests_Embed_Template extends WP_UnitTestCase {
|
||||
$doc = new DOMDocument();
|
||||
$this->assertTrue( $doc->loadHTML( $actual ) );
|
||||
$this->assertFalse( strpos( $actual, 'That embed can’t be found.' ) );
|
||||
$this->assertTrue( false !== strpos( $actual, 'Hello World' ) );
|
||||
$this->assertTrue( false !== strpos( $actual, 'canola.jpg' ) );
|
||||
$this->assertNotFalse( strpos( $actual, 'Hello World' ) );
|
||||
$this->assertNotFalse( strpos( $actual, 'canola.jpg' ) );
|
||||
}
|
||||
|
||||
function test_oembed_output_draft_post() {
|
||||
@ -114,7 +114,7 @@ class Tests_Embed_Template extends WP_UnitTestCase {
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$this->assertTrue( $doc->loadHTML( $actual ) );
|
||||
$this->assertTrue( false !== strpos( $actual, 'That embed can’t be found.' ) );
|
||||
$this->assertNotFalse( strpos( $actual, 'That embed can’t be found.' ) );
|
||||
}
|
||||
|
||||
function test_oembed_output_scheduled_post() {
|
||||
@ -136,7 +136,7 @@ class Tests_Embed_Template extends WP_UnitTestCase {
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$this->assertTrue( $doc->loadHTML( $actual ) );
|
||||
$this->assertTrue( false !== strpos( $actual, 'That embed can’t be found.' ) );
|
||||
$this->assertNotFalse( strpos( $actual, 'That embed can’t be found.' ) );
|
||||
}
|
||||
|
||||
function test_oembed_output_private_post() {
|
||||
@ -157,7 +157,7 @@ class Tests_Embed_Template extends WP_UnitTestCase {
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$this->assertTrue( $doc->loadHTML( $actual ) );
|
||||
$this->assertTrue( false !== strpos( $actual, 'That embed can’t be found.' ) );
|
||||
$this->assertNotFalse( strpos( $actual, 'That embed can’t be found.' ) );
|
||||
}
|
||||
|
||||
function test_oembed_output_private_post_with_permissions() {
|
||||
@ -182,8 +182,8 @@ class Tests_Embed_Template extends WP_UnitTestCase {
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$this->assertTrue( $doc->loadHTML( $actual ) );
|
||||
$this->assertTrue( false === strpos( $actual, 'That embed can’t be found.' ) );
|
||||
$this->assertTrue( false !== strpos( $actual, 'Hello World' ) );
|
||||
$this->assertFalse( strpos( $actual, 'That embed can’t be found.' ) );
|
||||
$this->assertNotFalse( strpos( $actual, 'Hello World' ) );
|
||||
}
|
||||
|
||||
function test_wp_embed_excerpt_more_no_embed() {
|
||||
|
@ -36,7 +36,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase {
|
||||
$actual = $this->oembed->get_html( $permalink );
|
||||
remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
|
||||
|
||||
$this->assertTrue( false !== $this->pre_oembed_result_filtered );
|
||||
$this->assertNotFalse( $this->pre_oembed_result_filtered );
|
||||
$this->assertEquals( $this->pre_oembed_result_filtered, $actual );
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase {
|
||||
$actual = $this->oembed->get_html( $permalink );
|
||||
remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
|
||||
|
||||
$this->assertTrue( false !== $this->pre_oembed_result_filtered );
|
||||
$this->assertNotFalse( $this->pre_oembed_result_filtered );
|
||||
$this->assertEquals( $this->pre_oembed_result_filtered, $actual );
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase {
|
||||
$actual = $this->oembed->get_html( 'https://example.com/' );
|
||||
remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
|
||||
|
||||
$this->assertTrue( false !== $this->pre_oembed_result_filtered );
|
||||
$this->assertNotFalse( $this->pre_oembed_result_filtered );
|
||||
$this->assertFalse( $actual );
|
||||
}
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase {
|
||||
function test_get_the_post_thumbnail_url_with_invalid_post() {
|
||||
set_post_thumbnail( self::$post, self::$attachment_id );
|
||||
|
||||
$this->assertTrue( false !== get_the_post_thumbnail_url( self::$post->ID ) );
|
||||
$this->assertNotFalse( get_the_post_thumbnail_url( self::$post->ID ) );
|
||||
|
||||
$deleted = wp_delete_post( self::$post->ID, true );
|
||||
$this->assertNotEmpty( $deleted );
|
||||
|
@ -101,7 +101,7 @@ class Tests_WP_Post_Type extends WP_UnitTestCase {
|
||||
$post_type_object->remove_rewrite_rules();
|
||||
$rewrite_tags_after = $wp_rewrite->rewritecode;
|
||||
|
||||
$this->assertTrue( false !== array_search( "%$post_type%", $rewrite_tags ) );
|
||||
$this->assertNotFalse( array_search( "%$post_type%", $rewrite_tags ) );
|
||||
$this->assertFalse( array_search( "%$post_type%", $rewrite_tags_after ) );
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ class Tests_WP_Taxonomy extends WP_UnitTestCase {
|
||||
$taxonomy_object->remove_rewrite_rules();
|
||||
$rewrite_tags_after = $wp_rewrite->rewritecode;
|
||||
|
||||
$this->assertTrue( false !== array_search( "%$taxonomy%", $rewrite_tags ) );
|
||||
$this->assertNotFalse( array_search( "%$taxonomy%", $rewrite_tags ) );
|
||||
$this->assertFalse( array_search( "%$taxonomy%", $rewrite_tags_after ) );
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
|
||||
$theme = wp_get_theme();
|
||||
$this->assertEquals( $style, (string) $theme );
|
||||
$this->assertNotSame( false, $theme->errors() );
|
||||
$this->assertNotFalse( $theme->errors() );
|
||||
$this->assertFalse( $theme->exists() );
|
||||
|
||||
// these return the bogus name - perhaps not ideal behaviour?
|
||||
|
@ -90,7 +90,7 @@ class Tests_Theme_Support extends WP_UnitTestCase {
|
||||
remove_theme_support( 'html5' );
|
||||
$this->assertFalse( current_theme_supports( 'html5' ) );
|
||||
$this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) );
|
||||
$this->assertNotSame( false, add_theme_support( 'html5' ) );
|
||||
$this->assertNotFalse( add_theme_support( 'html5' ) );
|
||||
$this->assertTrue( current_theme_supports( 'html5' ) );
|
||||
$this->assertTrue( current_theme_supports( 'html5', 'comment-form' ) );
|
||||
$this->assertTrue( current_theme_supports( 'html5', 'comment-list' ) );
|
||||
@ -108,7 +108,7 @@ class Tests_Theme_Support extends WP_UnitTestCase {
|
||||
$this->assertFalse( current_theme_supports( 'html5' ) );
|
||||
$this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) );
|
||||
$this->assertFalse( add_theme_support( 'html5', 'comment-form' ) );
|
||||
$this->assertNotSame( false, add_theme_support( 'html5', array( 'comment-form' ) ) );
|
||||
$this->assertNotFalse( add_theme_support( 'html5', array( 'comment-form' ) ) );
|
||||
$this->assertTrue( current_theme_supports( 'html5', 'comment-form' ) );
|
||||
|
||||
// This will return true, which might help a plugin author decide what markup to serve,
|
||||
@ -117,7 +117,7 @@ class Tests_Theme_Support extends WP_UnitTestCase {
|
||||
|
||||
// It appends, rather than replaces.
|
||||
$this->assertFalse( current_theme_supports( 'html5', 'comment-list' ) );
|
||||
$this->assertNotSame( false, add_theme_support( 'html5', array( 'comment-list' ) ) );
|
||||
$this->assertNotFalse( add_theme_support( 'html5', array( 'comment-list' ) ) );
|
||||
$this->assertTrue( current_theme_supports( 'html5', 'comment-form' ) );
|
||||
$this->assertTrue( current_theme_supports( 'html5', 'comment-list' ) );
|
||||
$this->assertFalse( current_theme_supports( 'html5', 'search-form' ) );
|
||||
|
Loading…
Reference in New Issue
Block a user