mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-15 14:20:24 +00:00
Build/Test Tools: Replace assertInternalType() usage in unit tests.
The `assertInternalType()` and `assertNotInternalType()` methods are deprecated in PHPUnit 8 and removed in PHPUnit 9. While WordPress test suite currently only supports PHPUnit up to 7.5.x, this allows us to switch to newer assertions ahead of adding full support for PHPUnit 8+. These methods introduced in PHPUnit 7.5 should be used as an alternative: * `assertIsArray()` * `assertIsBool()` * `assertIsFloat()` * `assertIsInt()` * `assertIsNumeric()` * `assertIsObject()` * `assertIsResource()` * `assertIsString()` * `assertIsScalar()` * `assertIsCallable()` * `assertIsIterable()` * `assertIsNotArray()` * `assertIsNotBool()` * `assertIsNotFloat()` * `assertIsNotInt()` * `assertIsNotNumeric()` * `assertIsNotObject()` * `assertIsNotResource()` * `assertIsNotString()` * `assertIsNotScalar()` * `assertIsNotCallable()` * `assertIsNotIterable()` As WordPress currently uses PHPUnit 5.7.x to run tests on PHP 5.6, polyfills for these methods are now added to the `WP_UnitTestCase` class for PHPUnit < 7.5. Props pbearne, jrf, dd32, SergeyBiryukov. Fixes #53491. See #46149. git-svn-id: https://develop.svn.wordpress.org/trunk@51331 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -344,10 +344,10 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
|
||||
* @return array Data.
|
||||
*/
|
||||
function filter_update_custom_css_data( $data, $args ) {
|
||||
$this->assertInternalType( 'array', $data );
|
||||
$this->assertIsArray( $data );
|
||||
$this->assertSameSets( array( 'css', 'preprocessed' ), array_keys( $data ) );
|
||||
$this->assertSame( '', $data['preprocessed'] );
|
||||
$this->assertInternalType( 'array', $args );
|
||||
$this->assertIsArray( $args );
|
||||
$this->assertSameSets( array( 'css', 'preprocessed', 'stylesheet' ), array_keys( $args ) );
|
||||
$this->assertSame( $args['css'], $data['css'] );
|
||||
$this->assertSame( $args['preprocessed'], $data['preprocessed'] );
|
||||
|
||||
@@ -677,9 +677,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertSameSets( $expected_setting_ids, array_keys( $changeset_values ) );
|
||||
|
||||
foreach ( array( 'widget_text[2]', 'widget_meta[2]' ) as $setting_id ) {
|
||||
$this->assertInternalType( 'array', $changeset_values[ $setting_id ] );
|
||||
$this->assertIsArray( $changeset_values[ $setting_id ] );
|
||||
$instance_data = $wp_customize->widgets->sanitize_widget_instance( $changeset_values[ $setting_id ] );
|
||||
$this->assertInternalType( 'array', $instance_data );
|
||||
$this->assertIsArray( $instance_data );
|
||||
$this->assertArrayHasKey( 'title', $instance_data );
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertNull( $wp_customize->changeset_post_id() );
|
||||
$this->assertSame( 1000, has_action( 'customize_register', array( $wp_customize, '_save_starter_content_changeset' ) ) );
|
||||
do_action( 'customize_register', $wp_customize ); // This will trigger the changeset save.
|
||||
$this->assertInternalType( 'int', $wp_customize->changeset_post_id() );
|
||||
$this->assertIsInt( $wp_customize->changeset_post_id() );
|
||||
$this->assertNotEmpty( $wp_customize->changeset_data() );
|
||||
foreach ( $wp_customize->changeset_data() as $setting_id => $setting_params ) {
|
||||
$this->assertArrayHasKey( 'starter_content', $setting_params );
|
||||
@@ -787,7 +787,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertSame( 'auto-draft', get_post( $posts_by_name['waffles'] )->post_status );
|
||||
$this->assertNotEquals( $changeset_data['blogname']['value'], get_option( 'blogname' ) );
|
||||
$r = $wp_customize->save_changeset_post( array( 'status' => 'publish' ) );
|
||||
$this->assertInternalType( 'array', $r );
|
||||
$this->assertIsArray( $r );
|
||||
$this->assertSame( 'publish', get_post( $posts_by_name['about'] )->post_status );
|
||||
$this->assertSame( 'inherit', get_post( $posts_by_name['waffles'] )->post_status );
|
||||
$this->assertSame( $changeset_data['blogname']['value'], get_option( 'blogname' ) );
|
||||
@@ -1041,7 +1041,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
'data' => $pre_saved_data,
|
||||
)
|
||||
);
|
||||
$this->assertInternalType( 'array', $r );
|
||||
$this->assertIsArray( $r );
|
||||
|
||||
$this->assertSame( $did_action['customize_save_validation_before'] + 1, did_action( 'customize_save_validation_before' ) );
|
||||
|
||||
@@ -1098,7 +1098,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
);
|
||||
$this->assertInstanceOf( 'WP_Error', $r );
|
||||
$this->assertSame( 'transaction_fail', $r->get_error_code() );
|
||||
$this->assertInternalType( 'array', $r->get_error_data() );
|
||||
$this->assertIsArray( $r->get_error_data() );
|
||||
$this->assertArrayHasKey( 'setting_validities', $r->get_error_data() );
|
||||
$error_data = $r->get_error_data();
|
||||
$this->assertArrayHasKey( 'blogname', $error_data['setting_validities'] );
|
||||
@@ -1137,7 +1137,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
),
|
||||
)
|
||||
);
|
||||
$this->assertInternalType( 'array', $r );
|
||||
$this->assertIsArray( $r );
|
||||
$this->assertArrayHasKey( 'setting_validities', $r );
|
||||
$this->assertTrue( $r['setting_validities']['blogname'] );
|
||||
$this->assertInstanceOf( 'WP_Error', $r['setting_validities']['bar_unknown'] );
|
||||
@@ -1205,7 +1205,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
),
|
||||
)
|
||||
);
|
||||
$this->assertInternalType( 'array', $r );
|
||||
$this->assertIsArray( $r );
|
||||
$this->assertSame( 'Do it live \o/', get_option( 'blogname' ) );
|
||||
$this->assertSame( 'trash', get_post_status( $post_id ) ); // Auto-trashed.
|
||||
$this->assertSame( $original_capabilities, wp_list_pluck( $manager->settings(), 'capability' ) );
|
||||
@@ -1422,8 +1422,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*/
|
||||
function filter_customize_changeset_save_data( $data, $context ) {
|
||||
$this->customize_changeset_save_data_call_count += 1;
|
||||
$this->assertInternalType( 'array', $data );
|
||||
$this->assertInternalType( 'array', $context );
|
||||
$this->assertIsArray( $data );
|
||||
$this->assertIsArray( $context );
|
||||
$this->assertArrayHasKey( 'uuid', $context );
|
||||
$this->assertArrayHasKey( 'title', $context );
|
||||
$this->assertArrayHasKey( 'status', $context );
|
||||
@@ -1513,7 +1513,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
),
|
||||
)
|
||||
);
|
||||
$this->assertInternalType( 'array', $r );
|
||||
$this->assertIsArray( $r );
|
||||
$this->assertSame(
|
||||
array_fill_keys( array( 'blogname', 'scratchpad', 'background_color' ), true ),
|
||||
$r['setting_validities']
|
||||
@@ -1540,7 +1540,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
),
|
||||
)
|
||||
);
|
||||
$this->assertInternalType( 'array', $r );
|
||||
$this->assertIsArray( $r );
|
||||
$this->assertSame(
|
||||
array_fill_keys( array( 'blogname', 'background_color' ), true ),
|
||||
$r['setting_validities']
|
||||
@@ -1569,7 +1569,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
'user_id' => self::$subscriber_user_id,
|
||||
)
|
||||
);
|
||||
$this->assertInternalType( 'array', $r );
|
||||
$this->assertIsArray( $r );
|
||||
$this->assertSame(
|
||||
array_fill_keys( array( 'blogname', 'scratchpad' ), true ),
|
||||
$r['setting_validities']
|
||||
@@ -1888,7 +1888,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
'autosave' => true,
|
||||
)
|
||||
);
|
||||
$this->assertInternalType( 'array', $r );
|
||||
$this->assertIsArray( $r );
|
||||
|
||||
// Verify that autosave happened.
|
||||
$autosave_revision = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
|
||||
@@ -2715,10 +2715,10 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$error->add( 'bad_letter', 'Bad letra', 123 );
|
||||
$error->add( 'bad_number', 'Bad number', array( 'number' => 123 ) );
|
||||
$validity = $this->manager->prepare_setting_validity_for_js( $error );
|
||||
$this->assertInternalType( 'array', $validity );
|
||||
$this->assertIsArray( $validity );
|
||||
foreach ( $error->errors as $code => $messages ) {
|
||||
$this->assertArrayHasKey( $code, $validity );
|
||||
$this->assertInternalType( 'array', $validity[ $code ] );
|
||||
$this->assertIsArray( $validity[ $code ] );
|
||||
$this->assertSame( implode( ' ', $messages ), $validity[ $code ]['message'] );
|
||||
$this->assertArrayHasKey( 'data', $validity[ $code ] );
|
||||
$this->assertSame( $validity[ $code ]['data'], $error->get_error_data( $code ) );
|
||||
@@ -2910,7 +2910,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @return array
|
||||
*/
|
||||
function filter_customize_dynamic_setting_args_for_test_dynamic_settings( $setting_args, $setting_id ) {
|
||||
$this->assertInternalType( 'string', $setting_id );
|
||||
$this->assertIsString( $setting_id );
|
||||
if ( in_array( $setting_id, array( 'foo', 'bar' ), true ) ) {
|
||||
$setting_args = array( 'default' => "dynamic_{$setting_id}_default" );
|
||||
}
|
||||
@@ -2927,8 +2927,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*/
|
||||
function filter_customize_dynamic_setting_class_for_test_dynamic_settings( $setting_class, $setting_id, $setting_args ) {
|
||||
$this->assertSame( 'WP_Customize_Setting', $setting_class );
|
||||
$this->assertInternalType( 'string', $setting_id );
|
||||
$this->assertInternalType( 'array', $setting_args );
|
||||
$this->assertIsString( $setting_id );
|
||||
$this->assertIsArray( $setting_args );
|
||||
return $setting_class;
|
||||
}
|
||||
|
||||
@@ -3039,7 +3039,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_nonces() {
|
||||
$nonces = $this->manager->get_nonces();
|
||||
$this->assertInternalType( 'array', $nonces );
|
||||
$this->assertIsArray( $nonces );
|
||||
$this->assertArrayHasKey( 'save', $nonces );
|
||||
$this->assertArrayHasKey( 'preview', $nonces );
|
||||
|
||||
@@ -3203,10 +3203,10 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @return array Components.
|
||||
*/
|
||||
function return_array_containing_widgets( $components, $customize_manager ) {
|
||||
$this->assertInternalType( 'array', $components );
|
||||
$this->assertIsArray( $components );
|
||||
$this->assertContains( 'widgets', $components );
|
||||
$this->assertContains( 'nav_menus', $components );
|
||||
$this->assertInternalType( 'array', $components );
|
||||
$this->assertIsArray( $components );
|
||||
$this->assertInstanceOf( 'WP_Customize_Manager', $customize_manager );
|
||||
return array( 'widgets' );
|
||||
}
|
||||
@@ -3220,10 +3220,10 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @return array Components.
|
||||
*/
|
||||
function return_array_containing_nav_menus( $components, $customize_manager ) {
|
||||
$this->assertInternalType( 'array', $components );
|
||||
$this->assertIsArray( $components );
|
||||
$this->assertContains( 'widgets', $components );
|
||||
$this->assertContains( 'nav_menus', $components );
|
||||
$this->assertInternalType( 'array', $components );
|
||||
$this->assertIsArray( $components );
|
||||
$this->assertInstanceOf( 'WP_Customize_Manager', $customize_manager );
|
||||
return array( 'nav_menus' );
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
$this->assertNull( $setting->previous_post_id );
|
||||
$this->assertNull( $setting->update_status );
|
||||
$this->assertNull( $setting->update_error );
|
||||
$this->assertInternalType( 'array', $setting->default );
|
||||
$this->assertIsArray( $setting->default );
|
||||
|
||||
$default = array(
|
||||
'object_id' => 0,
|
||||
@@ -533,7 +533,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
);
|
||||
foreach ( $valid_urls as $valid_url ) {
|
||||
$url_setting = $setting->sanitize( array( 'url' => $valid_url ) );
|
||||
$this->assertInternalType( 'array', $url_setting );
|
||||
$this->assertIsArray( $url_setting );
|
||||
$this->assertSame( $valid_url, $url_setting['url'] );
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
$this->assertNull( $setting->previous_term_id );
|
||||
$this->assertNull( $setting->update_status );
|
||||
$this->assertNull( $setting->update_error );
|
||||
$this->assertInternalType( 'array', $setting->default );
|
||||
$this->assertIsArray( $setting->default );
|
||||
foreach ( array( 'name', 'description', 'parent' ) as $key ) {
|
||||
$this->assertArrayHasKey( $key, $setting->default );
|
||||
}
|
||||
@@ -149,7 +149,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id );
|
||||
|
||||
$value = $setting->value();
|
||||
$this->assertInternalType( 'array', $value );
|
||||
$this->assertIsArray( $value );
|
||||
foreach ( array( 'name', 'description', 'parent' ) as $key ) {
|
||||
$this->assertArrayHasKey( $key, $value );
|
||||
}
|
||||
@@ -225,7 +225,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
$menus = wp_get_nav_menus();
|
||||
$menus_ids = wp_list_pluck( $menus, 'term_id' );
|
||||
$i = array_search( $menu_id, $menus_ids, true );
|
||||
$this->assertInternalType( 'int', $i, 'Update-previewed menu does not appear in wp_get_nav_menus()' );
|
||||
$this->assertIsInt( $i, 'Update-previewed menu does not appear in wp_get_nav_menus()' );
|
||||
$filtered_menu = $menus[ $i ];
|
||||
$this->assertSame( 'Name 2 \\o/', $filtered_menu->name );
|
||||
}
|
||||
@@ -270,7 +270,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
$menus = wp_get_nav_menus();
|
||||
$menus_ids = wp_list_pluck( $menus, 'term_id' );
|
||||
$i = array_search( $menu_id, $menus_ids, true );
|
||||
$this->assertInternalType( 'int', $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()' );
|
||||
$this->assertIsInt( $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()' );
|
||||
$filtered_menu = $menus[ $i ];
|
||||
$this->assertSame( 'New Menu Name 1 \\o/', $filtered_menu->name );
|
||||
}
|
||||
@@ -304,8 +304,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
|
||||
$this->wp_customize->set_post_value( $setting_id, false );
|
||||
|
||||
$this->assertInternalType( 'array', $setting->value() );
|
||||
$this->assertInternalType( 'object', wp_get_nav_menu_object( $menu_id ) );
|
||||
$this->assertIsArray( $setting->value() );
|
||||
$this->assertIsObject( wp_get_nav_menu_object( $menu_id ) );
|
||||
$setting->preview();
|
||||
$this->assertFalse( $setting->value() );
|
||||
$this->assertFalse( wp_get_nav_menu_object( $menu_id ) );
|
||||
|
||||
@@ -381,7 +381,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
$this->assertSame( $count + 1, $this->filter_count_customize_nav_menu_searched_items );
|
||||
$this->assertInternalType( 'array', $results );
|
||||
$this->assertIsArray( $results );
|
||||
$this->assertCount( 3, $results );
|
||||
remove_filter( 'customize_nav_menu_searched_items', array( $this, 'filter_search' ), 10 );
|
||||
|
||||
@@ -465,8 +465,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
* @return array Items.
|
||||
*/
|
||||
function filter_search( $items, $args ) {
|
||||
$this->assertInternalType( 'array', $items );
|
||||
$this->assertInternalType( 'array', $args );
|
||||
$this->assertIsArray( $items );
|
||||
$this->assertIsArray( $args );
|
||||
$this->assertArrayHasKey( 's', $args );
|
||||
$this->assertArrayHasKey( 'pagenum', $args );
|
||||
$this->filter_count_customize_nav_menu_searched_items += 1;
|
||||
@@ -804,13 +804,13 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$args = apply_filters( 'customize_dynamic_partial_args', false, 'nav_menu_instance[68b329da9893e34099c7d8ad5cb9c940]' );
|
||||
$this->assertInternalType( 'array', $args );
|
||||
$this->assertIsArray( $args );
|
||||
$this->assertSame( 'nav_menu_instance', $args['type'] );
|
||||
$this->assertSame( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] );
|
||||
$this->assertTrue( $args['container_inclusive'] );
|
||||
|
||||
$args = apply_filters( 'customize_dynamic_partial_args', array( 'fallback_refresh' => false ), 'nav_menu_instance[4099c7d8ad5cb9c94068b329da9893e3]' );
|
||||
$this->assertInternalType( 'array', $args );
|
||||
$this->assertIsArray( $args );
|
||||
$this->assertSame( 'nav_menu_instance', $args['type'] );
|
||||
$this->assertSame( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] );
|
||||
$this->assertTrue( $args['container_inclusive'] );
|
||||
|
||||
@@ -31,7 +31,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_construct_default_args() {
|
||||
$panel = new WP_Customize_Panel( $this->manager, 'foo' );
|
||||
$this->assertInternalType( 'int', $panel->instance_number );
|
||||
$this->assertIsInt( $panel->instance_number );
|
||||
$this->assertSame( $this->manager, $panel->manager );
|
||||
$this->assertSame( 'foo', $panel->id );
|
||||
$this->assertSame( 160, $panel->priority );
|
||||
@@ -125,7 +125,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
}
|
||||
$this->assertEmpty( $data['content'] );
|
||||
$this->assertTrue( $data['active'] );
|
||||
$this->assertInternalType( 'int', $data['instanceNumber'] );
|
||||
$this->assertIsInt( $data['instanceNumber'] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -166,7 +166,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
function filter_customize_partial_render( $rendered, $partial, $container_context ) {
|
||||
$this->assertTrue( false === $rendered || is_string( $rendered ) );
|
||||
$this->assertInstanceOf( 'WP_Customize_Partial', $partial );
|
||||
$this->assertInternalType( 'array', $container_context );
|
||||
$this->assertIsArray( $container_context );
|
||||
$this->count_filter_customize_partial_render += 1;
|
||||
return $rendered;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
$this->assertSame( sprintf( 'customize_partial_render_%s', $partial->id ), current_filter() );
|
||||
$this->assertTrue( false === $rendered || is_string( $rendered ) );
|
||||
$this->assertInstanceOf( 'WP_Customize_Partial', $partial );
|
||||
$this->assertInternalType( 'array', $container_context );
|
||||
$this->assertIsArray( $container_context );
|
||||
$this->count_filter_customize_partial_render_with_id += 1;
|
||||
return $rendered;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_construct_default_args() {
|
||||
$section = new WP_Customize_Section( $this->manager, 'foo' );
|
||||
$this->assertInternalType( 'int', $section->instance_number );
|
||||
$this->assertIsInt( $section->instance_number );
|
||||
$this->assertSame( $this->manager, $section->manager );
|
||||
$this->assertSame( 'foo', $section->id );
|
||||
$this->assertSame( 160, $section->priority );
|
||||
@@ -139,7 +139,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
}
|
||||
$this->assertEmpty( $data['content'] );
|
||||
$this->assertTrue( $data['active'] );
|
||||
$this->assertInternalType( 'int', $data['instanceNumber'] );
|
||||
$this->assertIsInt( $data['instanceNumber'] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -160,7 +160,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
}
|
||||
$output = json_decode( ob_get_clean(), true );
|
||||
$this->assertTrue( $output['success'] );
|
||||
$this->assertInternalType( 'array', $output['data'] );
|
||||
$this->assertIsArray( $output['data'] );
|
||||
$this->assertArrayHasKey( 'contents', $output['data'] );
|
||||
$this->assertArrayHasKey( 'errors', $output['data'] );
|
||||
$this->assertArrayHasKey( 'foo', $output['data']['contents'] );
|
||||
@@ -280,7 +280,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
* @return string
|
||||
*/
|
||||
function render_callback_blogname( $partial, $context ) {
|
||||
$this->assertInternalType( 'array', $context );
|
||||
$this->assertIsArray( $context );
|
||||
$this->assertInstanceOf( 'WP_Customize_Partial', $partial );
|
||||
return get_bloginfo( 'name', 'display' );
|
||||
}
|
||||
@@ -293,7 +293,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
* @return string
|
||||
*/
|
||||
function render_callback_blogdescription( $partial, $context ) {
|
||||
$this->assertInternalType( 'array', $context );
|
||||
$this->assertIsArray( $context );
|
||||
$this->assertInstanceOf( 'WP_Customize_Partial', $partial );
|
||||
$x = get_bloginfo( 'description', 'display' );
|
||||
return $x;
|
||||
@@ -374,7 +374,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
* @return array Response.
|
||||
*/
|
||||
function filter_customize_render_partials_response( $response, $component, $partial_placements ) {
|
||||
$this->assertInternalType( 'array', $response );
|
||||
$this->assertIsArray( $response );
|
||||
$this->assertInstanceOf( 'WP_Customize_Selective_Refresh', $component );
|
||||
if ( isset( $this->expected_partial_ids ) ) {
|
||||
$this->assertSameSets( $this->expected_partial_ids, array_keys( $partial_placements ) );
|
||||
|
||||
@@ -71,7 +71,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
* @see WP_Customize_Selective_Refresh::partials()
|
||||
*/
|
||||
function test_partials() {
|
||||
$this->assertInternalType( 'array', $this->selective_refresh->partials() );
|
||||
$this->assertIsArray( $this->selective_refresh->partials() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,9 +163,9 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
$html = ob_get_clean();
|
||||
$this->assertTrue( (bool) preg_match( '/_customizePartialRefreshExports = ({.+})/s', $html, $matches ) );
|
||||
$exported_data = json_decode( $matches[1], true );
|
||||
$this->assertInternalType( 'array', $exported_data );
|
||||
$this->assertIsArray( $exported_data );
|
||||
$this->assertArrayHasKey( 'partials', $exported_data );
|
||||
$this->assertInternalType( 'array', $exported_data['partials'] );
|
||||
$this->assertIsArray( $exported_data['partials'] );
|
||||
$this->assertArrayHasKey( 'blogname', $exported_data['partials'] );
|
||||
$this->assertArrayNotHasKey( 'top_secret_message', $exported_data['partials'] );
|
||||
$this->assertSame( '#site-title', $exported_data['partials']['blogname']['selector'] );
|
||||
@@ -208,7 +208,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
*/
|
||||
function filter_customize_dynamic_partial_args( $partial_args, $partial_id ) {
|
||||
$this->assertTrue( false === $partial_args || is_array( $partial_args ) );
|
||||
$this->assertInternalType( 'string', $partial_id );
|
||||
$this->assertIsString( $partial_id );
|
||||
|
||||
if ( preg_match( '/^recognized/', $partial_id ) ) {
|
||||
$partial_args = array(
|
||||
@@ -230,9 +230,9 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
* @return string
|
||||
*/
|
||||
function filter_customize_dynamic_partial_class( $partial_class, $partial_id, $partial_args ) {
|
||||
$this->assertInternalType( 'array', $partial_args );
|
||||
$this->assertInternalType( 'string', $partial_id );
|
||||
$this->assertInternalType( 'string', $partial_class );
|
||||
$this->assertIsArray( $partial_args );
|
||||
$this->assertIsString( $partial_id );
|
||||
$this->assertIsString( $partial_class );
|
||||
|
||||
if ( 'recognized-class' === $partial_id ) {
|
||||
$partial_class = 'Tested_Custom_Partial';
|
||||
|
||||
@@ -730,7 +730,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
*/
|
||||
public function filter_validate_for_test_validate( $validity, $value ) {
|
||||
$this->assertInstanceOf( 'WP_Error', $validity );
|
||||
$this->assertInternalType( 'string', $value );
|
||||
$this->assertIsString( $value );
|
||||
if ( sanitize_key( $value ) !== $value ) {
|
||||
$validity->add( 'invalid_key', 'Invalid key' );
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
$this->do_customize_boot_actions();
|
||||
|
||||
$selective_refreshable_widgets = $this->manager->widgets->get_selective_refreshable_widgets();
|
||||
$this->assertInternalType( 'array', $selective_refreshable_widgets );
|
||||
$this->assertIsArray( $selective_refreshable_widgets );
|
||||
$this->assertSame( count( $wp_widget_factory->widgets ), count( $selective_refreshable_widgets ) );
|
||||
$this->assertArrayHasKey( 'text', $selective_refreshable_widgets );
|
||||
$this->assertTrue( $selective_refreshable_widgets['text'] );
|
||||
@@ -620,7 +620,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
$this->assertArrayHasKey( 'sidebar_id', $params );
|
||||
$this->assertArrayHasKey( 'width', $params );
|
||||
$this->assertArrayHasKey( 'height', $params );
|
||||
$this->assertInternalType( 'bool', $params['is_wide'] );
|
||||
$this->assertIsBool( $params['is_wide'] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -677,7 +677,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
$this->assertArrayNotHasKey( $setting_id, $this->manager->unsanitized_post_values() );
|
||||
$result = $this->manager->widgets->call_widget_update( $widget_id );
|
||||
|
||||
$this->assertInternalType( 'array', $result );
|
||||
$this->assertIsArray( $result );
|
||||
$this->assertArrayHasKey( 'instance', $result );
|
||||
$this->assertArrayHasKey( 'form', $result );
|
||||
$this->assertSame( $instance, $result['instance'] );
|
||||
@@ -686,7 +686,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
$post_values = $this->manager->unsanitized_post_values();
|
||||
$this->assertArrayHasKey( $setting_id, $post_values );
|
||||
$post_value = $post_values[ $setting_id ];
|
||||
$this->assertInternalType( 'array', $post_value );
|
||||
$this->assertIsArray( $post_value );
|
||||
$this->assertArrayHasKey( 'title', $post_value );
|
||||
$this->assertArrayHasKey( 'encoded_serialized_instance', $post_value );
|
||||
$this->assertArrayHasKey( 'instance_hash_key', $post_value );
|
||||
@@ -703,13 +703,13 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
do_action( 'customize_register', $this->manager );
|
||||
|
||||
$args = apply_filters( 'customize_dynamic_partial_args', false, 'widget[search-2]' );
|
||||
$this->assertInternalType( 'array', $args );
|
||||
$this->assertIsArray( $args );
|
||||
$this->assertSame( 'widget', $args['type'] );
|
||||
$this->assertSame( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] );
|
||||
$this->assertTrue( $args['container_inclusive'] );
|
||||
|
||||
$args = apply_filters( 'customize_dynamic_partial_args', array( 'fallback_refresh' => false ), 'widget[search-2]' );
|
||||
$this->assertInternalType( 'array', $args );
|
||||
$this->assertIsArray( $args );
|
||||
$this->assertSame( 'widget', $args['type'] );
|
||||
$this->assertSame( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] );
|
||||
$this->assertTrue( $args['container_inclusive'] );
|
||||
|
||||
Reference in New Issue
Block a user