diff --git a/tests/phpunit/tests/option/multisite.php b/tests/phpunit/tests/option/multisite.php index c2d4a10047..98c28fbf50 100644 --- a/tests/phpunit/tests/option/multisite.php +++ b/tests/phpunit/tests/option/multisite.php @@ -11,6 +11,13 @@ if ( is_multisite() ) : */ class Tests_Option_Multisite extends WP_UnitTestCase { + /** + * @covers ::get_blog_option + * @covers ::get_option + * @covers ::add_blog_option + * @covers ::update_blog_option + * @covers ::delete_blog_option + */ public function test_from_same_site() { $key = __FUNCTION__ . '_1'; $key2 = __FUNCTION__ . '_2'; @@ -48,6 +55,13 @@ if ( is_multisite() ) : $this->assertFalse( get_option( $key2 ) ); // Check get_option(). } + /** + * @covers ::get_blog_option + * @covers ::get_option + * @covers ::add_blog_option + * @covers ::update_blog_option + * @covers ::delete_blog_option + */ public function test_from_same_site_with_null_blog_id() { $key = __FUNCTION__ . '_1'; $key2 = __FUNCTION__ . '_2'; @@ -84,6 +98,13 @@ if ( is_multisite() ) : $this->assertFalse( get_option( $key2 ) ); // Check get_option(). } + /** + * @covers ::get_blog_option + * @covers ::get_option + * @covers ::add_blog_option + * @covers ::update_blog_option + * @covers ::delete_blog_option + */ public function test_with_another_site() { $user_id = self::factory()->user->create(); $this->assertIsInt( $user_id ); @@ -133,6 +154,8 @@ if ( is_multisite() ) : /** * @group multisite + * + * @covers ::get_site_option */ public function test_site_notoptions() { $network_id = get_current_network_id(); @@ -151,9 +174,13 @@ if ( is_multisite() ) : $this->assertNotEmpty( $notoptions1 ); } + /** + * @covers ::users_can_register_signup_filter + * @covers ::get_site_option + */ public function test_users_can_register_signup_filter() { - $registration = get_site_option( 'registration' ); + get_site_option( 'registration' ); $this->assertFalse( users_can_register_signup_filter() ); update_site_option( 'registration', 'all' ); @@ -168,6 +195,9 @@ if ( is_multisite() ) : /** * @dataProvider data_illegal_names + * + * @covers ::update_site_option + * @covers ::get_site_option */ public function test_sanitize_network_option_illegal_names( $option_value, $sanitized_option_value ) { update_site_option( 'illegal_names', $option_value ); @@ -187,6 +217,9 @@ if ( is_multisite() ) : * * @param $option_value * @param $sanitized_option_value + * + * @covers ::update_site_option + * @covers ::get_site_option */ public function test_sanitize_network_option_limited_email_domains( $option_value, $sanitized_option_value ) { update_site_option( 'limited_email_domains', $option_value ); @@ -198,6 +231,9 @@ if ( is_multisite() ) : * * @param $option_value * @param $sanitized_option_value + * + * @covers ::update_site_option + * @covers ::get_site_option */ public function test_sanitize_network_option_banned_email_domains( $option_value, $sanitized_option_value ) { update_site_option( 'banned_email_domains', $option_value ); diff --git a/tests/phpunit/tests/option/networkOption.php b/tests/phpunit/tests/option/networkOption.php index 39351c861d..bfce484a8d 100644 --- a/tests/phpunit/tests/option/networkOption.php +++ b/tests/phpunit/tests/option/networkOption.php @@ -14,6 +14,8 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { /** * @group ms-required + * + * @covers ::add_site_option */ public function test_add_network_option_not_available_on_other_network() { $id = self::factory()->network->create(); @@ -26,6 +28,8 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { /** * @group ms-required + * + * @covers ::add_network_option */ public function test_add_network_option_available_on_same_network() { $id = self::factory()->network->create(); @@ -38,6 +42,8 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { /** * @group ms-required + * + * @covers ::delete_site_option */ public function test_delete_network_option_on_only_one_network() { $id = self::factory()->network->create(); @@ -53,6 +59,8 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { /** * @ticket 22846 * @group ms-excluded + * + * @covers ::add_network_option */ public function test_add_network_option_is_not_stored_as_autoload_option() { $key = __FUNCTION__; @@ -67,6 +75,8 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { /** * @ticket 22846 * @group ms-excluded + * + * @covers ::update_network_option */ public function test_update_network_option_is_not_stored_as_autoload_option() { $key = __FUNCTION__; @@ -83,6 +93,8 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { * * @param $network_id * @param $expected_response + * + * @covers ::add_network_option */ public function test_add_network_option_network_id_parameter( $network_id, $expected_response ) { $option = rand_str(); @@ -96,6 +108,8 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { * * @param $network_id * @param $expected_response + * + * @covers ::get_network_option */ public function test_get_network_option_network_id_parameter( $network_id, $expected_response ) { $option = rand_str(); @@ -125,6 +139,10 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { /** * @ticket 43506 * @group ms-required + * + * @covers ::get_network_option + * @covers ::wp_cache_get + * @covers ::wp_cache_delete */ public function test_get_network_option_sets_notoptions_if_option_found() { $network_id = get_current_network_id(); @@ -149,6 +167,9 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { /** * @ticket 43506 * @group ms-required + * + * @covers ::get_network_option + * @covers ::wp_cache_get */ public function test_get_network_option_sets_notoptions_if_option_not_found() { $network_id = get_current_network_id(); @@ -174,6 +195,8 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { * Ensure updating network options containing an object do not result in unneeded database calls. * * @ticket 44956 + * + * @covers ::update_network_option */ public function test_update_network_option_array_with_object() { $array_w_object = array( diff --git a/tests/phpunit/tests/option/option.php b/tests/phpunit/tests/option/option.php index 3a16afed42..db20253b86 100644 --- a/tests/phpunit/tests/option/option.php +++ b/tests/phpunit/tests/option/option.php @@ -9,6 +9,12 @@ class Tests_Option_Option extends WP_UnitTestCase { return 'foo'; } + /** + * @covers ::get_option + * @covers ::add_option + * @covers ::update_option + * @covers ::delete_option + */ public function test_the_basics() { $key = 'key1'; $key2 = 'key2'; @@ -34,6 +40,11 @@ class Tests_Option_Option extends WP_UnitTestCase { $this->assertFalse( get_option( $key2 ) ); } + /** + * @covers ::get_option + * @covers ::add_option + * @covers ::delete_option + */ public function test_default_filter() { $value = 'value'; @@ -61,6 +72,9 @@ class Tests_Option_Option extends WP_UnitTestCase { /** * @ticket 31047 + * + * @covers ::get_option + * @covers ::add_option */ public function test_add_option_should_respect_default_option_filter() { add_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); @@ -71,6 +85,12 @@ class Tests_Option_Option extends WP_UnitTestCase { $this->assertSame( 'bar', get_option( 'doesnotexist' ) ); } + /** + * @covers ::get_option + * @covers ::add_option + * @covers ::delete_option + * @covers ::update_option + */ public function test_serialized_data() { $key = __FUNCTION__; $value = array( @@ -93,6 +113,8 @@ class Tests_Option_Option extends WP_UnitTestCase { * @dataProvider data_bad_option_names * * @param mixed $option_name Option name. + * + * @covers ::get_option */ public function test_get_option_bad_option_name( $option_name ) { $this->assertFalse( get_option( $option_name ) ); @@ -104,6 +126,8 @@ class Tests_Option_Option extends WP_UnitTestCase { * @dataProvider data_bad_option_names * * @param mixed $option_name Option name. + * + * @covers ::add_option */ public function test_add_option_bad_option_name( $option_name ) { $this->assertFalse( add_option( $option_name, '' ) ); @@ -115,6 +139,8 @@ class Tests_Option_Option extends WP_UnitTestCase { * @dataProvider data_bad_option_names * * @param mixed $option_name Option name. + * + * @covers ::update_option */ public function test_update_option_bad_option_name( $option_name ) { $this->assertFalse( update_option( $option_name, '' ) ); @@ -126,6 +152,8 @@ class Tests_Option_Option extends WP_UnitTestCase { * @dataProvider data_bad_option_names * * @param mixed $option_name Option name. + * + * @covers ::delete_option */ public function test_delete_option_bad_option_name( $option_name ) { $this->assertFalse( delete_option( $option_name ) ); @@ -154,6 +182,8 @@ class Tests_Option_Option extends WP_UnitTestCase { * @dataProvider data_valid_but_undesired_option_names * * @param mixed $option_name Option name. + * + * @covers ::get_option */ public function test_get_option_valid_but_undesired_option_names( $option_name ) { $this->assertFalse( get_option( $option_name ) ); @@ -165,6 +195,8 @@ class Tests_Option_Option extends WP_UnitTestCase { * @dataProvider data_valid_but_undesired_option_names * * @param mixed $option_name Option name. + * + * @covers ::add_option */ public function test_add_option_valid_but_undesired_option_names( $option_name ) { $this->assertTrue( add_option( $option_name, '' ) ); @@ -176,6 +208,8 @@ class Tests_Option_Option extends WP_UnitTestCase { * @dataProvider data_valid_but_undesired_option_names * * @param mixed $option_name Option name. + * + * @covers ::update_option */ public function test_update_option_valid_but_undesired_option_names( $option_name ) { $this->assertTrue( update_option( $option_name, '' ) ); @@ -187,6 +221,8 @@ class Tests_Option_Option extends WP_UnitTestCase { * @dataProvider data_valid_but_undesired_option_names * * @param mixed $option_name Option name. + * + * @covers ::delete_option */ public function test_delete_option_valid_but_undesired_option_names( $option_name ) { $this->assertFalse( delete_option( $option_name ) ); @@ -210,6 +246,8 @@ class Tests_Option_Option extends WP_UnitTestCase { /** * @ticket 23289 + * + * @covers ::delete_option */ public function test_special_option_name_alloption() { $this->expectException( 'WPDieException' ); @@ -218,6 +256,8 @@ class Tests_Option_Option extends WP_UnitTestCase { /** * @ticket 23289 + * + * @covers ::delete_option */ public function test_special_option_name_notoptions() { $this->expectException( 'WPDieException' ); @@ -229,6 +269,8 @@ class Tests_Option_Option extends WP_UnitTestCase { * * @ticket 31119 * @dataProvider data_option_autoloading + * + * @covers ::add_option */ public function test_option_autoloading( $name, $autoload_value, $expected ) { global $wpdb; diff --git a/tests/phpunit/tests/option/registration.php b/tests/phpunit/tests/option/registration.php index d60acb9ef1..04991e4a33 100644 --- a/tests/phpunit/tests/option/registration.php +++ b/tests/phpunit/tests/option/registration.php @@ -4,6 +4,10 @@ * @group option */ class Tests_Option_Registration extends WP_UnitTestCase { + + /** + * @covers ::register_setting + */ public function test_register() { register_setting( 'test_group', 'test_option' ); @@ -19,6 +23,10 @@ class Tests_Option_Registration extends WP_UnitTestCase { $this->assertSame( '', $args['description'] ); } + /** + * @covers ::register_setting + * @covers ::apply_filters + */ public function test_register_with_callback() { register_setting( 'test_group', 'test_option', array( $this, 'filter_registered_setting' ) ); @@ -26,6 +34,11 @@ class Tests_Option_Registration extends WP_UnitTestCase { $this->assertSame( 'S-M-R-T', $filtered ); } + /** + * @covers ::register_setting + * @covers WP_REST_Settings_Controller + * @covers ::apply_filters + */ public function test_register_with_array() { register_setting( 'test_group', @@ -45,6 +58,8 @@ class Tests_Option_Registration extends WP_UnitTestCase { /** * @ticket 38176 + * + * @covers ::register_setting */ public function test_register_with_default() { register_setting( @@ -60,6 +75,8 @@ class Tests_Option_Registration extends WP_UnitTestCase { /** * @ticket 38176 + * + * @covers ::register_setting */ public function test_register_with_default_override() { register_setting( @@ -77,6 +94,10 @@ class Tests_Option_Registration extends WP_UnitTestCase { /** * @ticket 38930 + * + * @covers ::register_setting + * @covers ::add_option + * @covers ::get_option */ public function test_add_option_with_no_options_cache() { register_setting( @@ -93,6 +114,8 @@ class Tests_Option_Registration extends WP_UnitTestCase { /** * @expectedDeprecated register_setting + * + * @covers ::register_setting */ public function test_register_deprecated_group_misc() { register_setting( 'misc', 'test_option' ); @@ -100,6 +123,8 @@ class Tests_Option_Registration extends WP_UnitTestCase { /** * @expectedDeprecated register_setting + * + * @covers ::register_setting */ public function test_register_deprecated_group_privacy() { register_setting( 'privacy', 'test_option' ); @@ -107,6 +132,9 @@ class Tests_Option_Registration extends WP_UnitTestCase { /** * @ticket 43207 + * + * @covers ::register_setting + * @covers ::unregister_setting */ public function test_unregister_setting_removes_default() { register_setting( diff --git a/tests/phpunit/tests/option/sanitizeOption.php b/tests/phpunit/tests/option/sanitizeOption.php index 926b7885ca..bc0dd0843b 100644 --- a/tests/phpunit/tests/option/sanitizeOption.php +++ b/tests/phpunit/tests/option/sanitizeOption.php @@ -81,6 +81,8 @@ class Tests_Option_SanitizeOption extends WP_UnitTestCase { /** * @dataProvider sanitize_option_provider + * + * @covers ::sanitize_option */ public function test_sanitize_option( $option_name, $sanitized, $original ) { $this->assertSame( $sanitized, sanitize_option( $option_name, $original ) ); @@ -97,6 +99,8 @@ class Tests_Option_SanitizeOption extends WP_UnitTestCase { /** * @dataProvider upload_path_provider + * + * @covers ::sanitize_option */ public function test_sanitize_option_upload_path( $provided, $expected ) { $this->assertSame( $expected, sanitize_option( 'upload_path', $provided ) ); @@ -104,6 +108,8 @@ class Tests_Option_SanitizeOption extends WP_UnitTestCase { /** * @ticket 36122 + * + * @covers ::sanitize_option */ public function test_emoji_in_blogname_and_description() { global $wpdb; @@ -122,6 +128,9 @@ class Tests_Option_SanitizeOption extends WP_UnitTestCase { /** * @dataProvider permalink_structure_provider + * + * @covers ::sanitize_option + * @covers ::get_settings_errors */ public function test_sanitize_permalink_structure( $provided, $expected, $valid ) { global $wp_settings_errors; diff --git a/tests/phpunit/tests/option/siteOption.php b/tests/phpunit/tests/option/siteOption.php index b1b7dfc0a4..1cba141534 100644 --- a/tests/phpunit/tests/option/siteOption.php +++ b/tests/phpunit/tests/option/siteOption.php @@ -8,10 +8,18 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { return 'foo'; } + /** + * @covers ::get_site_option + */ public function test_get_site_option_returns_false_if_option_does_not_exist() { $this->assertFalse( get_site_option( 'doesnotexist' ) ); } + /** + * @covers ::add_site_option + * @covers ::delete_site_option + * @covers ::get_site_option + */ public function test_get_site_option_returns_false_after_deletion() { $key = __FUNCTION__; $value = __FUNCTION__; @@ -20,6 +28,10 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertFalse( get_site_option( $key ) ); } + /** + * @covers ::add_site_option + * @covers ::get_site_option + */ public function test_get_site_option_returns_value() { $key = __FUNCTION__; $value = __FUNCTION__; @@ -27,6 +39,11 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertSame( $value, get_site_option( $key ) ); } + /** + * @covers ::add_site_option + * @covers ::update_site_option + * @covers ::get_site_option + */ public function test_get_site_option_returns_updated_value() { $key = __FUNCTION__; $value = __FUNCTION__ . '_1'; @@ -36,6 +53,11 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertSame( $new_value, get_site_option( $key ) ); } + /** + * @covers ::add_filter + * @covers ::get_site_option + * @covers ::remove_filter + */ public function test_get_site_option_does_not_exist_returns_filtered_default_with_no_default_provided() { add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); $site_option = get_site_option( 'doesnotexist' ); @@ -43,6 +65,11 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertSame( 'foo', $site_option ); } + /** + * @covers ::add_filter + * @covers ::get_site_option + * @covers ::remove_filter + */ public function test_get_site_option_does_not_exist_returns_filtered_default_with_default_provided() { add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); $site_option = get_site_option( 'doesnotexist', 'bar' ); @@ -50,10 +77,17 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertSame( 'foo', $site_option ); } + /** + * @covers ::get_site_option + */ public function test_get_site_option_does_not_exist_returns_provided_default() { $this->assertSame( 'bar', get_site_option( 'doesnotexist', 'bar' ) ); } + /** + * @covers ::add_site_option + * @covers ::get_site_option + */ public function test_get_site_option_exists_does_not_return_provided_default() { $key = __FUNCTION__; $value = __FUNCTION__; @@ -61,6 +95,12 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertSame( $value, get_site_option( $key, 'foo' ) ); } + /** + * @covers ::add_site_option + * @covers ::add_filter + * @covers ::get_site_option + * @covers ::remove_filter + */ public function test_get_site_option_exists_does_not_return_filtered_default() { $key = __FUNCTION__; $value = __FUNCTION__; @@ -71,12 +111,18 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertSame( $value, $site_option ); } + /** + * @covers ::add_site_option + */ public function test_add_site_option_returns_true_for_new_option() { $key = __FUNCTION__; $value = __FUNCTION__; $this->assertTrue( add_site_option( $key, $value ) ); } + /** + * @covers ::add_site_option + */ public function test_add_site_option_returns_false_for_existing_option() { $key = __FUNCTION__; $value = __FUNCTION__; @@ -84,6 +130,10 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertFalse( add_site_option( $key, $value ) ); } + /** + * @covers ::add_site_option + * @covers ::update_site_option + */ public function test_update_site_option_returns_false_for_same_value() { $key = __FUNCTION__; $value = __FUNCTION__; @@ -91,6 +141,10 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertFalse( update_site_option( $key, $value ) ); } + /** + * @covers ::add_site_option + * @covers ::update_site_option + */ public function test_update_site_option_returns_true_for_new_value() { $key = 'key'; $value = 'value1'; @@ -99,6 +153,10 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertTrue( update_site_option( $key, $new_value ) ); } + /** + * @covers ::add_site_option + * @covers ::delete_site_option + */ public function test_delete_site_option_returns_true_if_option_exists() { $key = __FUNCTION__; $value = __FUNCTION__; @@ -106,6 +164,10 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertTrue( delete_site_option( $key ) ); } + /** + * @covers ::add_site_option + * @covers ::delete_site_option + */ public function test_delete_site_option_returns_false_if_option_does_not_exist() { $key = __FUNCTION__; $value = __FUNCTION__; @@ -114,6 +176,10 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertFalse( delete_site_option( $key ) ); } + /** + * @covers ::add_site_option + * @covers ::get_site_option + */ public function test_site_option_add_and_get_serialized_array() { $key = __FUNCTION__; $value = array( @@ -124,6 +190,10 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $this->assertSame( $value, get_site_option( $key ) ); } + /** + * @covers ::add_site_option + * @covers ::get_site_option + */ public function test_site_option_add_and_get_serialized_object() { $key = __FUNCTION__; $value = new stdClass(); @@ -137,6 +207,9 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { * Ensure update_site_option() will add options with false-y values. * * @ticket 15497 + * + * @covers ::update_site_option + * @covers ::get_site_option */ public function test_update_adds_falsey_value() { $key = __FUNCTION__; @@ -152,6 +225,8 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { * Ensure get_site_option() doesn't cache the default value for non-existent options. * * @ticket 18955 + * + * @covers ::get_site_option */ public function test_get_doesnt_cache_default_value() { $option = __FUNCTION__; diff --git a/tests/phpunit/tests/option/siteTransient.php b/tests/phpunit/tests/option/siteTransient.php index c654a724c5..774fc4a20a 100644 --- a/tests/phpunit/tests/option/siteTransient.php +++ b/tests/phpunit/tests/option/siteTransient.php @@ -13,6 +13,11 @@ class Tests_Option_SiteTransient extends WP_UnitTestCase { } } + /** + * @covers ::get_site_transient + * @covers ::set_site_transient + * @covers ::delete_site_transient + */ public function test_the_basics() { $key = 'key1'; $value = 'value1'; @@ -29,6 +34,11 @@ class Tests_Option_SiteTransient extends WP_UnitTestCase { $this->assertFalse( delete_site_transient( $key ) ); } + /** + * @covers ::get_site_transient + * @covers ::set_site_transient + * @covers ::delete_site_transient + */ public function test_serialized_data() { $key = __FUNCTION__; $value = array( @@ -48,6 +58,9 @@ class Tests_Option_SiteTransient extends WP_UnitTestCase { /** * @ticket 22846 * @group ms-excluded + * + * @covers ::set_site_transient + * @covers ::wp_load_alloptions */ public function test_set_site_transient_is_not_stored_as_autoload_option() { $key = 'not_autoloaded'; diff --git a/tests/phpunit/tests/option/slashes.php b/tests/phpunit/tests/option/slashes.php index 77f359b860..b7bc4f7748 100644 --- a/tests/phpunit/tests/option/slashes.php +++ b/tests/phpunit/tests/option/slashes.php @@ -22,6 +22,9 @@ class Tests_Option_Slashes extends WP_UnitTestCase { /** * Tests the model function that expects un-slashed data + * + * @covers ::add_option + * @covers ::get_option */ public function test_add_option() { add_option( 'slash_test_1', self::SLASH_1 ); @@ -37,6 +40,10 @@ class Tests_Option_Slashes extends WP_UnitTestCase { /** * Tests the model function that expects un-slashed data + * + * @covers ::add_option + * @covers ::update_option + * @covers ::get_option */ public function test_update_option() { add_option( 'slash_test_5', 'foo' ); diff --git a/tests/phpunit/tests/option/themeMods.php b/tests/phpunit/tests/option/themeMods.php index 1529d79fef..48512dc100 100644 --- a/tests/phpunit/tests/option/themeMods.php +++ b/tests/phpunit/tests/option/themeMods.php @@ -5,14 +5,24 @@ */ class Tests_Option_ThemeMods extends WP_UnitTestCase { + /** + * @covers ::get_theme_mod + */ public function test_theme_mod_default() { $this->assertFalse( get_theme_mod( 'non_existent' ) ); } + /** + * @covers ::get_theme_mod + */ public function test_theme_mod_defined_default() { $this->assertSame( 'default', get_theme_mod( 'non_existent', 'default' ) ); } + /** + * @covers ::get_theme_mod + * @covers ::set_theme_mod + */ public function test_theme_mod_set() { $expected = 'value'; set_theme_mod( 'test_name', $expected ); @@ -21,6 +31,8 @@ class Tests_Option_ThemeMods extends WP_UnitTestCase { /** * @ticket 51423 + * + * @covers ::set_theme_mod */ public function test_theme_mod_set_with_invalid_theme_mods_option() { $theme_slug = get_option( 'stylesheet' ); @@ -28,6 +40,10 @@ class Tests_Option_ThemeMods extends WP_UnitTestCase { self::test_theme_mod_set(); } + /** + * @covers ::get_theme_mod + * @covers ::set_theme_mod + */ public function test_theme_mod_update() { set_theme_mod( 'test_update', 'first_value' ); $expected = 'updated_value'; @@ -35,6 +51,11 @@ class Tests_Option_ThemeMods extends WP_UnitTestCase { $this->assertSame( $expected, get_theme_mod( 'test_update' ) ); } + /** + * @covers ::set_theme_mod + * @covers ::remove_theme_mod + * @covers ::get_theme_mod + */ public function test_theme_mod_remove() { set_theme_mod( 'test_remove', 'value' ); remove_theme_mod( 'test_remove' ); @@ -45,6 +66,8 @@ class Tests_Option_ThemeMods extends WP_UnitTestCase { * @ticket 34290 * * @dataProvider data_theme_mod_default_value_with_percent_symbols + * + * @covers ::get_theme_mod */ public function test_theme_mod_default_value_with_percent_symbols( $default, $expected ) { $this->assertSame( $expected, get_theme_mod( 'test_name', $default ) ); diff --git a/tests/phpunit/tests/option/transient.php b/tests/phpunit/tests/option/transient.php index e82dc594cc..cf10eaed1b 100644 --- a/tests/phpunit/tests/option/transient.php +++ b/tests/phpunit/tests/option/transient.php @@ -13,6 +13,11 @@ class Tests_Option_Transient extends WP_UnitTestCase { } } + /** + * @covers ::get_transient + * @covers ::set_transient + * @covers ::delete_transient + */ public function test_the_basics() { $key = 'key1'; $value = 'value1'; @@ -29,6 +34,11 @@ class Tests_Option_Transient extends WP_UnitTestCase { $this->assertFalse( delete_transient( $key ) ); } + /** + * @covers ::get_transient + * @covers ::set_transient + * @covers ::delete_transient + */ public function test_serialized_data() { $key = rand_str(); $value = array( @@ -47,6 +57,10 @@ class Tests_Option_Transient extends WP_UnitTestCase { /** * @ticket 22807 + * + * @covers ::get_option + * @covers ::set_transient + * @covers ::update_option */ public function test_transient_data_with_timeout() { $key = rand_str(); @@ -68,6 +82,11 @@ class Tests_Option_Transient extends WP_UnitTestCase { /** * @ticket 22807 + * + * @covers ::set_transient + * @covers ::get_transient + * @covers ::get_option + * @covers ::update_option */ public function test_transient_add_timeout() { $key = rand_str(); @@ -91,6 +110,9 @@ class Tests_Option_Transient extends WP_UnitTestCase { * If get_option( $transient_timeout ) returns false, don't bother trying to delete the transient. * * @ticket 30380 + * + * @covers ::set_transient + * @covers ::get_transient */ public function test_nonexistent_key_dont_delete_if_false() { // Create a bogus a transient. @@ -119,6 +141,9 @@ class Tests_Option_Transient extends WP_UnitTestCase { /** * @ticket 30380 + * + * @covers ::set_transient + * @covers ::get_transient */ public function test_nonexistent_key_old_timeout() { // Create a transient. diff --git a/tests/phpunit/tests/option/updateOption.php b/tests/phpunit/tests/option/updateOption.php index db2aab24a2..7832a7f8fb 100644 --- a/tests/phpunit/tests/option/updateOption.php +++ b/tests/phpunit/tests/option/updateOption.php @@ -6,6 +6,10 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { /** * @ticket 31047 + * + * @covers ::add_filter + * @covers ::update_option + * @covers ::remove_filter */ public function test_should_respect_default_option_filter_when_option_does_not_yet_exist_in_database() { add_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); @@ -18,6 +22,10 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { /** * @ticket 26394 + * + * @covers ::update_option + * @covers ::wp_load_alloptions + * @covers ::get_option */ public function test_should_set_autoload_yes_for_nonexistent_option_when_autoload_param_is_missing() { global $wpdb; @@ -38,6 +46,10 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { /** * @ticket 26394 + * + * @covers ::update_option + * @covers ::wp_load_alloptions + * @covers ::get_option */ public function test_should_set_autoload_yes_for_nonexistent_option_when_autoload_param_is_yes() { global $wpdb; @@ -58,6 +70,10 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { /** * @ticket 26394 + * + * @covers ::update_option + * @covers ::wp_load_alloptions + * @covers ::get_option */ public function test_should_set_autoload_no_for_nonexistent_option_when_autoload_param_is_no() { global $wpdb; @@ -79,6 +95,10 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { /** * @ticket 26394 + * + * @covers ::update_option + * @covers ::wp_load_alloptions + * @covers ::get_option */ public function test_should_set_autoload_no_for_nonexistent_option_when_autoload_param_is_false() { global $wpdb; @@ -100,6 +120,10 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { /** * @ticket 26394 + * + * @covers ::update_option + * @covers ::wp_load_alloptions + * @covers ::get_option */ public function test_autoload_should_be_updated_for_existing_option_when_value_is_changed() { global $wpdb; @@ -121,6 +145,10 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { /** * @ticket 26394 + * + * @covers ::update_option + * @covers ::wp_load_alloptions + * @covers ::get_option */ public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_unchanged() { global $wpdb; @@ -143,6 +171,10 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { /** * @ticket 26394 + * + * @covers ::update_option + * @covers ::wp_load_alloptions + * @covers ::get_option */ public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_changed_but_no_value_of_autoload_is_provided() { global $wpdb; @@ -160,13 +192,17 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { $before = $wpdb->num_queries; $value = get_option( 'foo' ); - // 'foo' should still be autoload=yes, so we should see no additional querios. + // 'foo' should still be autoload=yes, so we should see no additional queries. $this->assertSame( $before, $wpdb->num_queries ); $this->assertSame( $value, 'bar2' ); } /** * @ticket 38903 + * + * @covers ::add_option + * @covers ::get_num_queries + * @covers ::update_option */ public function test_update_option_array_with_object() { $array_w_object = array( diff --git a/tests/phpunit/tests/option/userSettings.php b/tests/phpunit/tests/option/userSettings.php index 38ef6bf67e..b2cc9dfbff 100644 --- a/tests/phpunit/tests/option/userSettings.php +++ b/tests/phpunit/tests/option/userSettings.php @@ -24,6 +24,11 @@ class Tests_Option_UserSettings extends WP_UnitTestCase { parent::tear_down(); } + /** + * @covers ::get_user_setting + * @covers ::get_all_user_settings + * @covers ::wp_set_all_user_settings + */ public function test_set_user_setting() { $foo = get_user_setting( 'foo' ); @@ -34,6 +39,11 @@ class Tests_Option_UserSettings extends WP_UnitTestCase { $this->assertSame( 'bar', get_user_setting( 'foo' ) ); } + /** + * @covers ::get_user_setting + * @covers ::get_all_user_settings + * @covers ::wp_set_all_user_settings + */ public function test_set_user_setting_dashes() { $foo = get_user_setting( 'foo' ); @@ -44,6 +54,11 @@ class Tests_Option_UserSettings extends WP_UnitTestCase { $this->assertSame( 'foo-bar-baz', get_user_setting( 'foo' ) ); } + /** + * @covers ::get_user_setting + * @covers ::get_all_user_settings + * @covers ::wp_set_all_user_settings + */ public function test_set_user_setting_strip_asterisks() { $foo = get_user_setting( 'foo' ); diff --git a/tests/phpunit/tests/option/wpLoadAlloptions.php b/tests/phpunit/tests/option/wpLoadAlloptions.php index 72f3866f56..b012e72435 100644 --- a/tests/phpunit/tests/option/wpLoadAlloptions.php +++ b/tests/phpunit/tests/option/wpLoadAlloptions.php @@ -12,12 +12,17 @@ class Tests_Option_wpLoadAlloptions extends WP_UnitTestCase { parent::tear_down(); } + /** + * @covers ::wp_cache_get + */ public function test_if_alloptions_is_cached() { $this->assertNotEmpty( wp_cache_get( 'alloptions', 'options' ) ); } /** * @depends test_if_alloptions_is_cached + * + * @covers ::wp_cache_delete */ public function test_if_cached_alloptions_is_deleted() { $this->assertTrue( wp_cache_delete( 'alloptions', 'options' ) ); @@ -25,6 +30,8 @@ class Tests_Option_wpLoadAlloptions extends WP_UnitTestCase { /** * @depends test_if_alloptions_is_cached + * + * @covers ::wp_load_alloptions */ public function test_if_alloptions_are_retrieved_from_cache() { global $wpdb; @@ -38,6 +45,8 @@ class Tests_Option_wpLoadAlloptions extends WP_UnitTestCase { /** * @depends test_if_cached_alloptions_is_deleted + * + * @covers ::wp_load_alloptions */ public function test_if_alloptions_are_retrieved_from_database() { global $wpdb; @@ -55,6 +64,8 @@ class Tests_Option_wpLoadAlloptions extends WP_UnitTestCase { /** * @depends test_if_cached_alloptions_is_deleted + * + * @covers ::wp_load_alloptions */ public function test_filter_pre_cache_alloptions_is_called() { $temp = wp_installing(); @@ -81,6 +92,8 @@ class Tests_Option_wpLoadAlloptions extends WP_UnitTestCase { /** * @depends test_if_alloptions_is_cached + * + * @covers ::wp_load_alloptions */ public function test_filter_pre_cache_alloptions_is_not_called() { $temp = wp_installing();