diff --git a/tests/phpunit/tests/pluggable/signatures.php b/tests/phpunit/tests/pluggable/signatures.php index 81fd079621916..649e69186cc34 100644 --- a/tests/phpunit/tests/pluggable/signatures.php +++ b/tests/phpunit/tests/pluggable/signatures.php @@ -14,6 +14,8 @@ class Tests_Pluggable_Signatures extends WP_UnitTestCase { * @ticket 33867 * * @dataProvider get_defined_pluggable_functions + * + * @coversNothing */ public function test_pluggable_function_signatures_match( $function_name ) { @@ -54,6 +56,8 @@ public function test_pluggable_function_signatures_match( $function_name ) { * * @ticket 33654 * @ticket 33867 + * + * @coversNothing */ public function test_all_pluggable_functions_exist() { diff --git a/tests/phpunit/tests/pluggable/wpMail.php b/tests/phpunit/tests/pluggable/wpMail.php index f7af48bc067e8..9d547bc5fa959 100644 --- a/tests/phpunit/tests/pluggable/wpMail.php +++ b/tests/phpunit/tests/pluggable/wpMail.php @@ -23,12 +23,17 @@ public function tear_down() { * when it encounters a line longer than 999 characters. But PHPMailer doesn't clean up after itself / presets * all variables, which means that following tests would fail. To solve this issue we set `$this->Encoding` * back to 8bit in `MockPHPMailer::preSend`. + * + * @covers ::wp_mail */ public function test_wp_mail_break_it() { $content = str_repeat( 'A', 1000 ); $this->assertTrue( wp_mail( WP_TESTS_EMAIL, 'Looong line testing', $content ) ); } + /** + * @covers ::wp_mail + */ public function test_wp_mail_custom_boundaries() { $to = 'user@example.com'; $subject = 'Test email with custom boundaries'; @@ -89,6 +94,8 @@ public function test_wp_mail_custom_boundaries() { /** * @ticket 17305 + * + * @covers ::wp_mail */ public function test_wp_mail_rfc2822_addresses() { $to = 'Name '; @@ -119,6 +126,8 @@ public function test_wp_mail_rfc2822_addresses() { /** * @ticket 17305 + * + * @covers ::wp_mail */ public function test_wp_mail_multiple_rfc2822_to_addresses() { $to = 'Name , Another Name '; @@ -137,6 +146,9 @@ public function test_wp_mail_multiple_rfc2822_to_addresses() { $this->assertSameIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); } + /** + * @covers ::wp_mail + */ public function test_wp_mail_multiple_to_addresses() { $to = 'address@tld.com, another_address@different-tld.com'; $subject = 'RFC2822 Testing'; @@ -152,6 +164,8 @@ public function test_wp_mail_multiple_to_addresses() { /** * @ticket 18463 + * + * @covers ::wp_mail */ public function test_wp_mail_to_address_no_name() { $to = ''; @@ -167,6 +181,8 @@ public function test_wp_mail_to_address_no_name() { /** * @ticket 23642 + * + * @covers ::wp_mail */ public function test_wp_mail_return_value() { // No errors. @@ -181,6 +197,8 @@ public function test_wp_mail_return_value() { /** * @ticket 30266 + * + * @covers ::wp_mail */ public function test_wp_mail_with_valid_from_header() { $to = 'address@tld.com'; @@ -219,6 +237,8 @@ public function test_wp_mail_with_from_header_missing_space() { /** * @ticket 30266 + * + * @covers ::wp_mail */ public function test_wp_mail_with_empty_from_header() { $to = 'address@tld.com'; @@ -235,6 +255,8 @@ public function test_wp_mail_with_empty_from_header() { /** * @ticket 30266 + * + * @covers ::wp_mail */ public function test_wp_mail_with_empty_from_name_for_the_from_header() { $to = 'address@tld.com'; @@ -273,6 +295,8 @@ public function test_wp_mail_with_empty_home_url() { /** * @ticket 30266 + * + * @covers ::wp_mail */ public function test_wp_mail_with_valid_content_type_header() { $to = 'address@tld.com'; @@ -289,6 +313,8 @@ public function test_wp_mail_with_valid_content_type_header() { /** * @ticket 30266 + * + * @covers ::wp_mail */ public function test_wp_mail_with_empty_content_type_header() { $to = 'address@tld.com'; @@ -305,6 +331,8 @@ public function test_wp_mail_with_empty_content_type_header() { /** * @ticket 30266 + * + * @covers ::wp_mail */ public function test_wp_mail_with_empty_charset_for_the_content_type_header() { $to = 'address@tld.com'; @@ -321,6 +349,8 @@ public function test_wp_mail_with_empty_charset_for_the_content_type_header() { /** * @ticket 43542 + * + * @covers ::wp_mail */ public function test_wp_mail_does_not_duplicate_mime_version_header() { $to = 'user@example.com'; @@ -354,6 +384,8 @@ public function wp_mail_set_text_message( $mailer ) { * https://tools.ietf.org/html/rfc2045#section-6.1 * * @ticket 28039 + * + * @covers ::wp_mail */ public function test_wp_mail_content_transfer_encoding_in_quoted_printable_multipart() { add_action( 'phpmailer_init', array( $this, 'wp_mail_quoted_printable' ) ); @@ -371,6 +403,8 @@ public function test_wp_mail_content_transfer_encoding_in_quoted_printable_multi /** * @ticket 21659 + * + * @covers ::wp_mail */ public function test_wp_mail_addresses_arent_encoded() { $to = 'Lukáš To '; @@ -413,6 +447,8 @@ public function test_wp_mail_addresses_arent_encoded() { * set it correctly. * * @ticket 37736 + * + * @covers ::wp_mail */ public function test_wp_mail_sender_not_set() { wp_mail( 'user@example.org', 'Testing the Sender field', 'The Sender field should not have been set.' ); @@ -424,6 +460,8 @@ public function test_wp_mail_sender_not_set() { /** * @ticket 35598 + * + * @covers ::wp_mail */ public function test_phpmailer_exception_thrown() { $to = 'an_invalid_address'; @@ -512,6 +550,8 @@ public function test_wp_mail_sends_attachments_with_custom_name() { /** * @ticket 50720 + * + * @coversNothing */ public function test_phpmailer_validator() { $phpmailer = $GLOBALS['phpmailer']; @@ -522,6 +562,8 @@ public function test_phpmailer_validator() { * Test for short-circuiting wp_mail(). * * @ticket 35069 + * + * @covers ::wp_mail */ public function test_wp_mail_can_be_shortcircuited() { $result1 = wp_mail( WP_TESTS_EMAIL, 'Foo', 'Bar' ); diff --git a/tests/phpunit/tests/pomo/mo.php b/tests/phpunit/tests/pomo/mo.php index 7ae73abf6c7ec..d68e205424295 100644 --- a/tests/phpunit/tests/pomo/mo.php +++ b/tests/phpunit/tests/pomo/mo.php @@ -5,6 +5,9 @@ */ class Tests_POMO_MO extends WP_UnitTestCase { + /** + * @covers MO::import_from_file + */ public function test_mo_simple() { $mo = new MO(); $mo->import_from_file( DIR_TESTDATA . '/pomo/simple.mo' ); @@ -20,6 +23,9 @@ public function test_mo_simple() { $this->assertSame( array( 'yes' ), $mo->entries["kuku\nruku"]->translations ); } + /** + * @covers MO::translate_plural + */ public function test_mo_plural() { $mo = new MO(); $mo->import_from_file( DIR_TESTDATA . '/pomo/plural.mo' ); @@ -46,6 +52,9 @@ public function test_mo_plural() { $this->assertSame( 'twoey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', -8 ) ); } + /** + * @covers Translation_Entry::__construct + */ public function test_mo_context() { $mo = new MO(); $mo->import_from_file( DIR_TESTDATA . '/pomo/context.mo' ); @@ -72,6 +81,9 @@ public function test_mo_context() { $this->assertSame( 'not so dragon', $mo->entries[ $single_entry->key() ]->context ); } + /** + * @covers Translation_Entry::merge_with + */ public function test_translations_merge() { $host = new Translations(); $host->add_entry( new Translation_Entry( array( 'singular' => 'pink' ) ) ); @@ -84,6 +96,9 @@ public function test_translations_merge() { $this->assertSame( array(), array_diff( array( 'pink', 'green', 'red' ), array_keys( $host->entries ) ) ); } + /** + * @covers MO::export_to_file + */ public function test_export_mo_file() { $entries = array(); $entries[] = new Translation_Entry( @@ -142,6 +157,9 @@ public function test_export_mo_file() { } } + /** + * @covers MO::export_to_file + */ public function test_export_should_not_include_empty_translations() { $entries = array(); $mo = new MO(); @@ -161,6 +179,9 @@ public function test_export_should_not_include_empty_translations() { $this->assertCount( 0, $again->entries ); } + /** + * @covers MO::translate_plural + */ public function test_nplurals_with_backslashn() { $mo = new MO(); $mo->import_from_file( DIR_TESTDATA . '/pomo/bad_nplurals.mo' ); @@ -169,6 +190,9 @@ public function test_nplurals_with_backslashn() { $this->assertSame( '%d foros', $mo->translate_plural( '%d forum', '%d forums', -1 ) ); } + /** + * @covers MO::import_from_file + */ public function disabled_test_performance() { $start = microtime( true ); $mo = new MO(); @@ -176,6 +200,9 @@ public function disabled_test_performance() { // echo "\nPerformance: ".(microtime(true) - $start)."\n"; } + /** + * @covers Translation_Entry::translations + */ public function test_overloaded_mb_functions() { if ( ( ini_get( 'mbstring.func_overload' ) & 2 ) === 0 ) { $this->markTestSkipped( 'This test requires mbstring.func_overload to be enabled.' ); @@ -186,6 +213,9 @@ public function test_overloaded_mb_functions() { $this->assertSame( array( 'Табло' ), $mo->entries['Dashboard']->translations ); } + /** + * @covers MO::import_from_file + */ public function test_load_pot_file() { $mo = new MO(); $this->assertFalse( $mo->import_from_file( DIR_TESTDATA . '/pomo/mo.pot' ) ); diff --git a/tests/phpunit/tests/pomo/noopTranslations.php b/tests/phpunit/tests/pomo/noopTranslations.php index 44f46c1880f43..593936e99077d 100644 --- a/tests/phpunit/tests/pomo/noopTranslations.php +++ b/tests/phpunit/tests/pomo/noopTranslations.php @@ -39,30 +39,48 @@ public function set_up() { ); } + /** + * @covers NOOP_Translations::get_header + */ public function test_get_header() { $this->assertFalse( $this->noop->get_header( 'Content-Type' ) ); } + /** + * @covers NOOP_Translations::add_entry + */ public function test_add_entry() { $this->noop->add_entry( $this->entry ); $this->assertSame( array(), $this->noop->entries ); } + /** + * @covers NOOP_Translations::set_header + */ public function test_set_header() { $this->noop->set_header( 'header', 'value' ); $this->assertSame( array(), $this->noop->headers ); } + /** + * @covers NOOP_Translations::translate_entry + */ public function test_translate_entry() { $this->noop->add_entry( $this->entry ); $this->assertFalse( $this->noop->translate_entry( $this->entry ) ); } + /** + * @covers NOOP_Translations::translate + */ public function test_translate() { $this->noop->add_entry( $this->entry ); $this->assertSame( 'baba', $this->noop->translate( 'baba' ) ); } + /** + * @covers NOOP_Translations::translate_plural + */ public function test_plural() { $this->noop->add_entry( $this->plural_entry ); $this->assertSame( 'dyado', $this->noop->translate_plural( 'dyado', 'dyados', 1 ) ); diff --git a/tests/phpunit/tests/pomo/pluralForms.php b/tests/phpunit/tests/pomo/pluralForms.php index b676735c59bac..fedf199233f22 100644 --- a/tests/phpunit/tests/pomo/pluralForms.php +++ b/tests/phpunit/tests/pomo/pluralForms.php @@ -41,6 +41,8 @@ protected static function parenthesize_plural_expression( $expression ) { * @ticket 41562 * @dataProvider data_locales * @group external-http + * + * @covers GP_Locales::locales */ public function test_regression( $lang, $nplurals, $expression ) { require_once dirname( __DIR__, 2 ) . '/includes/plural-form-function.php'; @@ -94,6 +96,8 @@ public static function data_locales() { /** * @ticket 41562 * @dataProvider data_simple + * + * @covers Plural_Forms::__construct */ public function test_simple( $expression, $expected ) { $plural_forms = new Plural_Forms( $expression ); @@ -161,6 +165,8 @@ public static function data_simple() { * * @ticket 41562 * @dataProvider data_exceptions + * + * @covers Plural_Forms::__construct */ public function test_exceptions( $expression, $expected_message, $call_get ) { $this->expectException( 'Exception' ); @@ -214,6 +220,8 @@ public function data_exceptions() { /** * @ticket 41562 + * + * @covers Plural_Forms::__construct */ public function test_cache() { $mock = $this->getMockBuilder( 'Plural_Forms' ) diff --git a/tests/phpunit/tests/pomo/po.php b/tests/phpunit/tests/pomo/po.php index eeaf0aad14fea..280e498124bed 100644 --- a/tests/phpunit/tests/pomo/po.php +++ b/tests/phpunit/tests/pomo/po.php @@ -51,6 +51,9 @@ public static function set_up_before_class() { require_once ABSPATH . 'wp-includes/pomo/po.php'; } + /** + * @covers PO::prepend_each_line + */ public function test_prepend_each_line() { $po = new PO(); $this->assertSame( 'baba_', $po->prepend_each_line( '', 'baba_' ) ); @@ -58,6 +61,9 @@ public function test_prepend_each_line() { $this->assertSame( "# baba\n# dyado\n# \n", $po->prepend_each_line( "baba\ndyado\n\n", '# ' ) ); } + /** + * @covers PO::poify + */ public function test_poify() { $po = new PO(); // Simple. @@ -80,6 +86,9 @@ public function test_poify() { $this->assertSameIgnoreEOL( self::PO_MAIL, $po->poify( $mail ) ); } + /** + * @covers PO::unpoify + */ public function test_unpoify() { $po = new PO(); $this->assertSame( 'baba', $po->unpoify( '"baba"' ) ); @@ -96,6 +105,9 @@ public function test_unpoify() { $this->assertSameIgnoreEOL( $mail, $po->unpoify( self::PO_MAIL ) ); } + /** + * @covers PO::export_entry + */ public function test_export_entry() { $po = new PO(); $entry = new Translation_Entry( array( 'singular' => 'baba' ) ); @@ -221,6 +233,9 @@ public function test_export_entry() { ); } + /** + * @covers PO::export_entries + */ public function test_export_entries() { $entry = new Translation_Entry( array( 'singular' => 'baba' ) ); $entry2 = new Translation_Entry( array( 'singular' => 'dyado' ) ); @@ -230,6 +245,9 @@ public function test_export_entries() { $this->assertSame( "msgid \"baba\"\nmsgstr \"\"\n\nmsgid \"dyado\"\nmsgstr \"\"", $po->export_entries() ); } + /** + * @covers PO::export_headers + */ public function test_export_headers() { $po = new PO(); $po->set_header( 'Project-Id-Version', 'WordPress 2.6-bleeding' ); @@ -237,6 +255,9 @@ public function test_export_headers() { $this->assertSame( "msgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: WordPress 2.6-bleeding\\n\"\n\"POT-Creation-Date: 2008-04-08 18:00+0000\\n\"", $po->export_headers() ); } + /** + * @covers PO::export + */ public function test_export() { $po = new PO(); $entry = new Translation_Entry( array( 'singular' => 'baba' ) ); @@ -250,6 +271,9 @@ public function test_export() { } + /** + * @covers PO::export_to_file + */ public function test_export_to_file() { $po = new PO(); $entry = new Translation_Entry( array( 'singular' => 'baba' ) ); @@ -268,6 +292,9 @@ public function test_export_to_file() { $this->assertSame( $po->export(), file_get_contents( $temp_fn2 ) ); } + /** + * @covers PO::import_from_file + */ public function test_import_from_file() { $po = new PO(); $res = $po->import_from_file( DIR_TESTDATA . '/pomo/simple.po' ); @@ -327,11 +354,17 @@ public function test_import_from_file() { $this->assertEquals( $end_quote_entry, $po->entries[ $end_quote_entry->key() ] ); } + /** + * @covers PO::import_from_file + */ public function test_import_from_entry_file_should_give_false() { $po = new PO(); $this->assertFalse( $po->import_from_file( DIR_TESTDATA . '/pomo/empty.po' ) ); } + /** + * @covers PO::import_from_file + */ public function test_import_from_file_with_windows_line_endings_should_work_as_with_unix_line_endings() { $po = new PO(); $this->assertTrue( $po->import_from_file( DIR_TESTDATA . '/pomo/windows-line-endings.po' ) ); diff --git a/tests/phpunit/tests/pomo/translationEntry.php b/tests/phpunit/tests/pomo/translationEntry.php index 24d7d093d9f55..ce81fe8d348e7 100644 --- a/tests/phpunit/tests/pomo/translationEntry.php +++ b/tests/phpunit/tests/pomo/translationEntry.php @@ -5,6 +5,9 @@ */ class Tests_POMO_TranslationEntry extends WP_UnitTestCase { + /** + * @covers Translation_Entry::__construct + */ public function test_create_entry() { // No singular => empty object. $entry = new Translation_Entry(); @@ -29,6 +32,9 @@ public function test_create_entry() { $this->assertSame( array(), $entry->flags ); } + /** + * @covers Translation_Entry::key + */ public function test_key() { $entry_baba = new Translation_Entry( array( 'singular' => 'baba' ) ); $entry_dyado = new Translation_Entry( array( 'singular' => 'dyado' ) ); diff --git a/tests/phpunit/tests/pomo/translations.php b/tests/phpunit/tests/pomo/translations.php index 0d2a3383b0f77..09269e40e6aca 100644 --- a/tests/phpunit/tests/pomo/translations.php +++ b/tests/phpunit/tests/pomo/translations.php @@ -5,6 +5,9 @@ */ class Tests_POMO_Translations extends WP_UnitTestCase { + /** + * @covers Translations::add_entry + */ public function test_add_entry() { $entry = new Translation_Entry( array( 'singular' => 'baba' ) ); $entry2 = new Translation_Entry( array( 'singular' => 'dyado' ) ); @@ -42,6 +45,9 @@ public function test_add_entry() { $this->assertSame( $entry->key(), $entries[0]->key() ); } + /** + * @covers Translations::translate + */ public function test_translate() { $entry1 = new Translation_Entry( array( @@ -65,6 +71,9 @@ public function test_translate() { $this->assertSame( 'babaz', $domain->translate( 'babaz' ) ); } + /** + * @covers Translations::translate_plural + */ public function test_translate_plural() { $entry_incomplete = new Translation_Entry( array( @@ -105,6 +114,10 @@ public function test_translate_plural() { $this->assertSame( 'dyadoy', $domain->translate_plural( 'dyado', 'dyados', -18881 ) ); } + /** + * @covers Translations::translate + * @covers Translation_Entry::merge_with + */ public function test_digit_and_merge() { $entry_digit_1 = new Translation_Entry( array( diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 548c5eb2cabf8..e690eb2dc1d20 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -49,6 +49,9 @@ public function test_parse_post_content_single_page() { $this->assertSame( array( 'Page 0' ), $pages ); } + /** + * @covers ::setup_postdata + */ public function test_parse_post_content_multi_page() { global $multipage, $pages, $numpages; @@ -66,6 +69,9 @@ public function test_parse_post_content_multi_page() { $this->assertSame( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages ); } + /** + * @covers ::setup_postdata + */ public function test_parse_post_content_remaining_single_page() { global $multipage, $pages, $numpages; @@ -83,6 +89,9 @@ public function test_parse_post_content_remaining_single_page() { $this->assertSame( array( 'Page 0' ), $pages ); } + /** + * @covers ::setup_postdata + */ public function test_parse_post_content_remaining_multi_page() { global $multipage, $pages, $numpages; @@ -102,6 +111,8 @@ public function test_parse_post_content_remaining_multi_page() { /** * @ticket 16746 + * + * @covers ::setup_postdata */ public function test_parse_post_content_starting_with_nextpage() { global $multipage, $pages, $numpages; @@ -122,6 +133,8 @@ public function test_parse_post_content_starting_with_nextpage() { /** * @ticket 16746 + * + * @covers ::setup_postdata */ public function test_parse_post_content_starting_with_nextpage_multi() { global $multipage, $pages, $numpages; @@ -142,6 +155,8 @@ public function test_parse_post_content_starting_with_nextpage_multi() { /** * @ticket 24803 + * + * @covers ::wp_count_posts */ public function test_wp_count_posts() { $post_type = rand_str( 20 ); @@ -161,6 +176,9 @@ public function test_wp_count_posts() { $this->assertEquals( new stdClass(), $count ); } + /** + * @covers ::wp_count_posts + */ public function test_wp_count_posts_filtered() { $post_type = rand_str( 20 ); register_post_type( $post_type ); @@ -186,6 +204,9 @@ public function filter_wp_count_posts( $counts ) { return $counts; } + /** + * @covers ::wp_count_posts + */ public function test_wp_count_posts_insert_invalidation() { $post_ids = self::factory()->post->create_many( 3 ); $initial_counts = wp_count_posts(); @@ -206,6 +227,9 @@ public function test_wp_count_posts_insert_invalidation() { $this->assertNotEquals( $initial_counts->publish, $after_draft_counts->publish ); } + /** + * @covers ::wp_count_posts + */ public function test_wp_count_posts_trash_invalidation() { $post_ids = self::factory()->post->create_many( 3 ); $initial_counts = wp_count_posts(); @@ -226,6 +250,8 @@ public function test_wp_count_posts_trash_invalidation() { /** * @ticket 49685 + * + * @covers ::wp_count_posts */ public function test_wp_count_posts_status_changes_visible() { self::factory()->post->create_many( 3 ); @@ -242,6 +268,8 @@ public function test_wp_count_posts_status_changes_visible() { /** * @ticket 25566 + * + * @covers ::wp_tag_cloud */ public function test_wp_tag_cloud_link_with_post_type() { $post_type = 'new_post_type'; @@ -277,6 +305,8 @@ public function test_wp_tag_cloud_link_with_post_type() { /** * @ticket 21212 + * + * @covers ::edit_post */ public function test_utf8mb3_post_saves_with_emoji() { global $wpdb; @@ -318,6 +348,8 @@ public function test_utf8mb3_post_saves_with_emoji() { * without the `publish_posts` capability, it should stay sticky. * * @ticket 24153 + * + * @covers ::stick_post */ public function test_user_without_publish_posts_cannot_affect_sticky() { // Create a sticky post. @@ -356,6 +388,8 @@ public function test_user_without_publish_posts_cannot_affect_sticky() { * without the `publish_posts` capability, it should stay sticky. * * @ticket 24153 + * + * @covers ::stick_post */ public function test_user_without_publish_posts_cannot_affect_sticky_with_edit_post() { // Create a sticky post. @@ -396,6 +430,8 @@ public function test_user_without_publish_posts_cannot_affect_sticky_with_edit_p * Test that hooks are fired when post gets stuck and unstuck. * * @ticket 35600 + * + * @covers ::stick_post */ public function test_hooks_fire_when_post_gets_stuck_and_unstuck() { $post_id = self::factory()->post->create(); @@ -450,6 +486,8 @@ public function test_wp_delete_post_reassign_hierarchical_post_type() { * * @see wp_unique_post_slug() * @ticket 21112 + * + * @covers ::wp_insert_post */ public function test_pre_wp_unique_post_slug_filter() { add_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 ); diff --git a/tests/phpunit/tests/post/attachments.php b/tests/phpunit/tests/post/attachments.php index 2922c185d28ee..2511713a8383b 100644 --- a/tests/phpunit/tests/post/attachments.php +++ b/tests/phpunit/tests/post/attachments.php @@ -13,6 +13,9 @@ public function tear_down() { parent::tear_down(); } + /** + * @covers ::wp_upload_bits + */ public function test_insert_bogus_image() { $filename = rand_str() . '.jpg'; $contents = rand_str(); @@ -21,6 +24,9 @@ public function test_insert_bogus_image() { $this->assertEmpty( $upload['error'] ); } + /** + * @covers ::wp_insert_attachment + */ public function test_insert_image_no_thumb() { // This image is smaller than the thumbnail size so it won't have one. @@ -56,6 +62,8 @@ public function test_insert_image_no_thumb() { /** * @requires function imagejpeg + * + * @covers ::wp_insert_attachment */ public function test_insert_image_thumb_only() { update_option( 'medium_size_w', 0 ); @@ -107,6 +115,8 @@ public function test_insert_image_thumb_only() { /** * @requires function imagejpeg + * + * @covers ::wp_insert_attachment */ public function test_insert_image_medium_sizes() { update_option( 'medium_size_w', 400 ); @@ -164,6 +174,8 @@ public function test_insert_image_medium_sizes() { /** * @requires function imagejpeg + * + * @covers ::wp_insert_attachment */ public function test_insert_image_delete() { update_option( 'medium_size_w', 400 ); @@ -212,6 +224,8 @@ public function test_insert_image_delete() { * * @ticket 18310 * @ticket 21963 + * + * @covers ::wp_insert_attachment */ public function test_insert_image_without_guid() { // This image is smaller than the thumbnail size so it won't have one. @@ -230,6 +244,9 @@ public function test_insert_image_without_guid() { /** * @ticket 21963 + * + * @covers ::wp_insert_attachment + * @covers ::wp_update_post */ public function test_update_attachment_fields() { $filename = ( DIR_TESTDATA . '/images/test-image.jpg' ); @@ -256,6 +273,8 @@ public function test_update_attachment_fields() { /** * @ticket 29646 + * + * @covers ::wp_insert_attachment */ public function test_update_orphan_attachment_parent() { $filename = ( DIR_TESTDATA . '/images/test-image.jpg' ); @@ -285,6 +304,8 @@ public function test_update_orphan_attachment_parent() { /** * @ticket 15928 + * + * @covers ::wp_get_attachment_url */ public function test_wp_get_attachment_url_should_not_force_https_when_current_page_is_non_ssl_and_siteurl_is_non_ssl() { $siteurl = get_option( 'siteurl' ); @@ -310,6 +331,8 @@ public function test_wp_get_attachment_url_should_not_force_https_when_current_p * @ticket 15928 * * This situation (current request is non-SSL but siteurl is https) should never arise. + * + * @covers ::wp_get_attachment_url */ public function test_wp_get_attachment_url_should_not_force_https_when_current_page_is_non_ssl_and_siteurl_is_ssl() { $siteurl = get_option( 'siteurl' ); @@ -335,6 +358,8 @@ public function test_wp_get_attachment_url_should_not_force_https_when_current_p * @ticket 15928 * * Canonical siteurl is non-SSL, but SSL support is available/optional. + * + * @covers ::wp_get_attachment_url */ public function test_wp_get_attachment_url_should_force_https_with_https_on_same_host_when_siteurl_is_non_ssl_but_ssl_is_available() { $siteurl = get_option( 'siteurl' ); @@ -363,6 +388,8 @@ public function test_wp_get_attachment_url_should_force_https_with_https_on_same /** * @ticket 15928 + * + * @covers ::wp_get_attachment_url */ public function test_wp_get_attachment_url_with_https_on_same_host_when_siteurl_is_https() { $siteurl = get_option( 'siteurl' ); @@ -391,6 +418,8 @@ public function test_wp_get_attachment_url_with_https_on_same_host_when_siteurl_ /** * @ticket 15928 + * + * @covers ::wp_get_attachment_url */ public function test_wp_get_attachment_url_should_not_force_https_when_administering_over_https_but_siteurl_is_not_https() { $siteurl = get_option( 'siteurl' ); @@ -415,6 +444,8 @@ public function test_wp_get_attachment_url_should_not_force_https_when_administe /** * @ticket 15928 + * + * @covers ::wp_get_attachment_url */ public function test_wp_get_attachment_url_should_force_https_when_administering_over_https_and_siteurl_is_https() { // Set https upload URL. @@ -440,6 +471,10 @@ public function test_wp_get_attachment_url_should_force_https_when_administering $this->assertSame( 'https', parse_url( $url, PHP_URL_SCHEME ) ); } + /** + * @covers ::wp_attachment_is_image + * @covers ::wp_attachment_is + */ public function test_wp_attachment_is() { $filename = DIR_TESTDATA . '/images/test-image.jpg'; $contents = file_get_contents( $filename ); @@ -452,7 +487,10 @@ public function test_wp_attachment_is() { $this->assertFalse( wp_attachment_is( 'audio', $attachment_id ) ); $this->assertFalse( wp_attachment_is( 'video', $attachment_id ) ); } - + /** + * @covers ::wp_attachment_is_image + * @covers ::wp_attachment_is + */ public function test_wp_attachment_is_default() { // On Multisite, psd is not an allowed mime type by default. if ( is_multisite() ) { @@ -475,6 +513,9 @@ public function test_wp_attachment_is_default() { } } + /** + * @covers ::wp_upload_bits + */ public function test_upload_mimes_filter_is_applied() { $filename = DIR_TESTDATA . '/images/test-image.jpg'; $contents = file_get_contents( $filename ); @@ -504,6 +545,8 @@ public function disallow_jpg_mime_type( $mimes ) { /** * @ticket 33012 + * + * @covers ::wp_mime_type_icon */ public function test_wp_mime_type_icon() { $icon = wp_mime_type_icon(); @@ -513,6 +556,8 @@ public function test_wp_mime_type_icon() { /** * @ticket 33012 + * + * @covers ::wp_mime_type_icon */ public function test_wp_mime_type_icon_video() { $icon = wp_mime_type_icon( 'video/mp4' ); diff --git a/tests/phpunit/tests/post/filtering.php b/tests/phpunit/tests/post/filtering.php index 5947a29d43cfc..f692543c3c890 100644 --- a/tests/phpunit/tests/post/filtering.php +++ b/tests/phpunit/tests/post/filtering.php @@ -8,6 +8,8 @@ * * @group post * @group formatting + * + * @covers ::wp_insert_post */ class Tests_Post_Filtering extends WP_UnitTestCase { public function set_up() { @@ -21,7 +23,9 @@ public function tear_down() { parent::tear_down(); } - // A simple test to make sure unclosed tags are fixed. + /** + * A simple test to make sure unclosed tags are fixed. + */ public function test_post_content_unknown_tag() { $content = <<assertSame( $expected, $post->post_content ); } - // A simple test to make sure unbalanced tags are fixed. + /** + * A simple test to make sure unbalanced tags are fixed. + */ public function test_post_content_unbalanced_tag() { $content = <<assertSame( $expected, $post->post_content ); } - // Test KSES filtering of disallowed attribute. + /** + * Test KSES filtering of disallowed attribute. + */ + public function test_post_content_disallowed_attr() { $content = <<assertSame( $expected, $post->post_content ); } - // Make sure unbalanced tags are untouched when the balance option is off. + // + + /** + * Make sure unbalanced tags are untouched when the balance option is off. + */ public function test_post_content_nobalance_nextpage_more() { update_option( 'use_balanceTags', 0 ); diff --git a/tests/phpunit/tests/post/formats.php b/tests/phpunit/tests/post/formats.php index 1cb96907082f5..f46133860ff56 100644 --- a/tests/phpunit/tests/post/formats.php +++ b/tests/phpunit/tests/post/formats.php @@ -4,6 +4,10 @@ * @group post */ class Tests_Post_Formats extends WP_UnitTestCase { + + /** + * @covers ::get_post_format + */ public function test_set_get_post_format_for_post() { $post_id = self::factory()->post->create(); @@ -31,6 +35,8 @@ public function test_set_get_post_format_for_post() { /** * @ticket 22473 + * + * @covers ::get_post_format */ public function test_set_get_post_format_for_page() { $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); @@ -64,6 +70,9 @@ public function test_set_get_post_format_for_page() { remove_post_type_support( 'page', 'post-formats' ); } + /** + * @covers ::has_post_format + */ public function test_has_format() { $post_id = self::factory()->post->create(); @@ -92,6 +101,8 @@ public function test_has_format() { /** * @ticket 23570 + * + * @covers ::get_url_in_content */ public function test_get_url_in_content() { $link = 'http://nytimes.com'; diff --git a/tests/phpunit/tests/post/getLastPostDate.php b/tests/phpunit/tests/post/getLastPostDate.php index 8941c5282775c..be4014aac5037 100644 --- a/tests/phpunit/tests/post/getLastPostDate.php +++ b/tests/phpunit/tests/post/getLastPostDate.php @@ -2,6 +2,7 @@ /** * @group post + * @covers ::get_lastpostdate */ class Tests_Post_GetLastPostDate extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/post/getLastPostModified.php b/tests/phpunit/tests/post/getLastPostModified.php index 45b2cb651dcfe..7eaa0b4683c43 100644 --- a/tests/phpunit/tests/post/getLastPostModified.php +++ b/tests/phpunit/tests/post/getLastPostModified.php @@ -2,6 +2,7 @@ /** * @group post + * @covers ::get_lastpostmodified */ class Tests_Post_GetLastPostModified extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/post/getPageByPath.php b/tests/phpunit/tests/post/getPageByPath.php index 8db0274249bed..075453df9ff3d 100644 --- a/tests/phpunit/tests/post/getPageByPath.php +++ b/tests/phpunit/tests/post/getPageByPath.php @@ -2,6 +2,7 @@ /** * @group post + * @covers ::get_page_by_path */ class Tests_Post_GetPageByPath extends WP_UnitTestCase { /** diff --git a/tests/phpunit/tests/post/getPageChildren.php b/tests/phpunit/tests/post/getPageChildren.php index 208fdf3b36686..a468b9c86b657 100644 --- a/tests/phpunit/tests/post/getPageChildren.php +++ b/tests/phpunit/tests/post/getPageChildren.php @@ -2,6 +2,7 @@ /** * @group post + * @covers ::get_page_children */ class Tests_Post_GetPageChildren extends WP_UnitTestCase { protected $pages = array(); diff --git a/tests/phpunit/tests/post/getPageUri.php b/tests/phpunit/tests/post/getPageUri.php index c6799902ce1ec..de96e3d6d5136 100644 --- a/tests/phpunit/tests/post/getPageUri.php +++ b/tests/phpunit/tests/post/getPageUri.php @@ -2,6 +2,7 @@ /** * @group post + * @covers ::get_page_uri */ class Tests_Post_GetPageUri extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php index 76735bae86296..4d297f7625dcc 100644 --- a/tests/phpunit/tests/post/getPages.php +++ b/tests/phpunit/tests/post/getPages.php @@ -8,6 +8,8 @@ class Tests_Post_GetPages extends WP_UnitTestCase { /** * @ticket 23167 + * + * @covers ::get_pages */ public function test_get_pages_cache() { self::factory()->post->create_many( 3, array( 'post_type' => 'page' ) ); @@ -120,6 +122,8 @@ public function test_get_pages_cache_empty() { /** * @ticket 40669 + * + * @covers ::get_pages */ public function test_get_pages_cache_should_be_invalidated_by_add_post_meta() { $posts = self::factory()->post->create_many( @@ -156,6 +160,8 @@ public function test_get_pages_cache_should_be_invalidated_by_add_post_meta() { /** * @ticket 40669 + * + * @covers ::get_pages */ public function test_get_pages_cache_should_be_invalidated_by_update_post_meta() { $posts = self::factory()->post->create_many( @@ -193,6 +199,8 @@ public function test_get_pages_cache_should_be_invalidated_by_update_post_meta() /** * @ticket 40669 + * + * @covers ::get_pages */ public function test_get_pages_cache_should_be_invalidated_by_delete_post_meta() { $posts = self::factory()->post->create_many( @@ -230,6 +238,8 @@ public function test_get_pages_cache_should_be_invalidated_by_delete_post_meta() /** * @ticket 40669 + * + * @covers ::get_pages */ public function test_get_pages_cache_should_be_invalidated_by_delete_post_meta_by_key() { $posts = self::factory()->post->create_many( @@ -267,6 +277,8 @@ public function test_get_pages_cache_should_be_invalidated_by_delete_post_meta_b /** * @ticket 20376 + * + * @covers ::get_pages */ public function test_get_pages_meta() { $posts = self::factory()->post->create_many( 3, array( 'post_type' => 'page' ) ); @@ -297,6 +309,8 @@ public function test_get_pages_meta() { /** * @ticket 22074 + * + * @covers ::get_pages */ public function test_get_pages_include_exclude() { $page_ids = array(); @@ -605,6 +619,8 @@ public function test_get_pages_exclude_tree() { /** * @ticket 9470 + * + * @covers ::get_pages */ public function test_get_pages_parent() { $page_id1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); @@ -663,6 +679,8 @@ public function test_get_pages_parent() { /** * @ticket 22208 + * + * @covers ::get_pages */ public function test_get_children_fields_ids() { $post_id = self::factory()->post->create(); @@ -679,6 +697,8 @@ public function test_get_children_fields_ids() { /** * @ticket 25750 + * + * @covers ::get_pages */ public function test_get_pages_hierarchical_and_no_parent() { global $wpdb; @@ -729,6 +749,8 @@ public function test_get_pages_hierarchical_and_no_parent() { /** * @ticket 18701 + * + * @covers ::get_pages */ public function test_get_pages_hierarchical_empty_child_of() { $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); @@ -775,6 +797,8 @@ public function test_get_pages_hierarchical_empty_child_of() { /** * @ticket 18701 + * + * @covers ::get_pages */ public function test_get_pages_non_hierarchical_empty_child_of() { $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); @@ -811,6 +835,8 @@ public function test_get_pages_non_hierarchical_empty_child_of() { /** * @ticket 18701 + * + * @covers ::get_pages */ public function test_get_pages_hierarchical_non_empty_child_of() { $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); @@ -854,6 +880,8 @@ public function test_get_pages_hierarchical_non_empty_child_of() { /** * @ticket 18701 + * + * @covers ::get_pages */ public function test_get_pages_non_hierarchical_non_empty_child_of() { $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); @@ -919,6 +947,8 @@ public function test_get_pages_post_type() { /** * @ticket 12821 + * + * @covers ::wp_list_pages */ public function test_get_pages_post_status() { register_post_status( @@ -961,6 +991,8 @@ public function test_get_pages_offset() { /** * @ticket 12821 + * + * @covers ::get_pages */ public function test_get_pages_author() { $author_1 = self::factory()->user->create( @@ -1071,6 +1103,8 @@ public function test_get_pages_multiple_authors_by_user_login() { /** * @ticket 12821 + * + * @covers ::get_pages */ public function test_get_pages_orderby() { global $wpdb; diff --git a/tests/phpunit/tests/post/getPostStatus.php b/tests/phpunit/tests/post/getPostStatus.php index 6cce8251f5d7d..7d24a63751716 100644 --- a/tests/phpunit/tests/post/getPostStatus.php +++ b/tests/phpunit/tests/post/getPostStatus.php @@ -2,6 +2,7 @@ /** * @group post + * @covers ::get_post_status */ class Tests_Post_GetPostStatus extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/post/getPostTypeLabels.php b/tests/phpunit/tests/post/getPostTypeLabels.php index 2a0e7f0d32ab1..4f14a4258ea93 100644 --- a/tests/phpunit/tests/post/getPostTypeLabels.php +++ b/tests/phpunit/tests/post/getPostTypeLabels.php @@ -2,8 +2,11 @@ /** * @group post + * + * @covers ::get_post_type_labels */ class Tests_Post_GetPostTypeLabels extends WP_UnitTestCase { + public function test_returns_an_object() { $this->assertIsObject( get_post_type_labels( @@ -56,7 +59,6 @@ public function test_name_admin_bar_label_should_fall_back_to_singular_name() { $this->assertSame( 'Foo', $labels->name_admin_bar ); } - public function test_name_admin_bar_label_should_fall_back_to_post_type_name() { $labels = get_post_type_labels( (object) array( diff --git a/tests/phpunit/tests/post/getPosts.php b/tests/phpunit/tests/post/getPosts.php index dac071f1aff49..4a9b0a7862c47 100644 --- a/tests/phpunit/tests/post/getPosts.php +++ b/tests/phpunit/tests/post/getPosts.php @@ -3,8 +3,11 @@ /** * @group post * @group query + * + * @covers ::get_posts */ class Tests_Post_GetPosts extends WP_UnitTestCase { + public function test_offset_should_be_null_by_default() { $p1 = self::factory()->post->create( array( diff --git a/tests/phpunit/tests/post/getPostsByAuthorSql.php b/tests/phpunit/tests/post/getPostsByAuthorSql.php index fc6f1e85267d9..5fdc045fd2dc7 100644 --- a/tests/phpunit/tests/post/getPostsByAuthorSql.php +++ b/tests/phpunit/tests/post/getPostsByAuthorSql.php @@ -5,21 +5,33 @@ */ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { + /** + * @covers ::get_posts_by_author_sql + */ public function test_post_type_post() { $maybe_string = get_posts_by_author_sql( 'post' ); $this->assertStringContainsString( "post_type = 'post'", $maybe_string ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_post_type_page() { $maybe_string = get_posts_by_author_sql( 'page' ); $this->assertStringContainsString( "post_type = 'page'", $maybe_string ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_non_existent_post_type() { $maybe_string = get_posts_by_author_sql( 'non_existent_post_type' ); $this->assertStringContainsString( '1 = 0', $maybe_string ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_multiple_post_types() { register_post_type( 'foo' ); register_post_type( 'bar' ); @@ -32,31 +44,49 @@ public function test_multiple_post_types() { _unregister_post_type( 'bar' ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_full_true() { $maybe_string = get_posts_by_author_sql( 'post', true ); $this->assertMatchesRegularExpression( '/^WHERE /', $maybe_string ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_full_false() { $maybe_string = get_posts_by_author_sql( 'post', false ); $this->assertDoesNotMatchRegularExpression( '/^WHERE /', $maybe_string ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_post_type_clause_should_be_included_when_full_is_true() { $maybe_string = get_posts_by_author_sql( 'post', true ); $this->assertStringContainsString( "post_type = 'post'", $maybe_string ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_post_type_clause_should_be_included_when_full_is_false() { $maybe_string = get_posts_by_author_sql( 'post', false ); $this->assertStringContainsString( "post_type = 'post'", $maybe_string ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_post_author_should_create_post_author_clause() { $maybe_string = get_posts_by_author_sql( 'post', true, 1 ); $this->assertStringContainsString( 'post_author = 1', $maybe_string ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_public_only_true_should_not_allow_any_private_posts_for_loggedin_user() { $current_user = get_current_user_id(); $u = self::factory()->user->create(); @@ -68,6 +98,9 @@ public function test_public_only_true_should_not_allow_any_private_posts_for_log wp_set_current_user( $current_user ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_public_only_should_default_to_false() { $current_user = get_current_user_id(); $u = self::factory()->user->create(); @@ -78,6 +111,9 @@ public function test_public_only_should_default_to_false() { wp_set_current_user( $current_user ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_current_user_matches_post_author() { $current_user = get_current_user_id(); $u = self::factory()->user->create(); @@ -89,6 +125,9 @@ public function test_public_only_false_should_allow_current_user_access_to_own_p wp_set_current_user( $current_user ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_public_only_false_should_not_allow_access_to_private_posts_if_current_user_is_not_post_author() { $current_user = get_current_user_id(); $u1 = self::factory()->user->create(); @@ -101,6 +140,9 @@ public function test_public_only_false_should_not_allow_access_to_private_posts_ wp_set_current_user( $current_user ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_post_author_is_not_provided() { $current_user = get_current_user_id(); $u = self::factory()->user->create(); @@ -113,6 +155,9 @@ public function test_public_only_false_should_allow_current_user_access_to_own_p wp_set_current_user( $current_user ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_administrator_should_have_access_to_private_posts_when_public_only_is_false() { $current_user = get_current_user_id(); $u = self::factory()->user->create( array( 'role' => 'administrator' ) ); @@ -125,6 +170,9 @@ public function test_administrator_should_have_access_to_private_posts_when_publ wp_set_current_user( $current_user ); } + /** + * @covers ::get_posts_by_author_sql + */ public function test_user_has_access_only_to_private_posts_for_certain_post_types() { register_post_type( 'foo', array( 'capabilities' => array( 'read_private_posts' => 'read_private_foo' ) ) ); register_post_type( 'bar', array( 'capabilities' => array( 'read_private_posts' => 'read_private_bar' ) ) ); diff --git a/tests/phpunit/tests/post/getTheContent.php b/tests/phpunit/tests/post/getTheContent.php index 91f0b621f37ee..8ed1562af8435 100644 --- a/tests/phpunit/tests/post/getTheContent.php +++ b/tests/phpunit/tests/post/getTheContent.php @@ -3,6 +3,7 @@ /** * @group post * @group formatting + * @covers ::get_the_content */ class Tests_Post_GetTheContent extends WP_UnitTestCase { /** diff --git a/tests/phpunit/tests/post/getTheExcerpt.php b/tests/phpunit/tests/post/getTheExcerpt.php index 49fae7b69587b..8470acea03cd7 100644 --- a/tests/phpunit/tests/post/getTheExcerpt.php +++ b/tests/phpunit/tests/post/getTheExcerpt.php @@ -3,6 +3,7 @@ /** * @group post * @group formatting + * @covers ::get_the_excerpt */ class Tests_Post_GetTheExcerpt extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/post/isPostPubliclyViewable.php b/tests/phpunit/tests/post/isPostPubliclyViewable.php index 094d5eb408d7a..bd1a5e119fd05 100644 --- a/tests/phpunit/tests/post/isPostPubliclyViewable.php +++ b/tests/phpunit/tests/post/isPostPubliclyViewable.php @@ -2,6 +2,7 @@ /** * @group post + * @covers ::is_post_publicly_viewable */ class Tests_Post_IsPostPubliclyViewable extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/post/isPostStatusViewable.php b/tests/phpunit/tests/post/isPostStatusViewable.php index 3f9818bbd648e..51f7064fcdde3 100644 --- a/tests/phpunit/tests/post/isPostStatusViewable.php +++ b/tests/phpunit/tests/post/isPostStatusViewable.php @@ -2,6 +2,7 @@ /** * @group post + * @covers ::is_post_status_viewable */ class Tests_Post_IsPostStatusViewable extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/post/isPostTypeViewable.php b/tests/phpunit/tests/post/isPostTypeViewable.php index 1e642a810d1b9..547162d6e1949 100644 --- a/tests/phpunit/tests/post/isPostTypeViewable.php +++ b/tests/phpunit/tests/post/isPostTypeViewable.php @@ -2,8 +2,11 @@ /** * @group post + * + * @covers ::is_post_type_viewable */ class Tests_Post_IsPostTypeViewable extends WP_UnitTestCase { + public function test_should_return_false_for_non_publicly_queryable_types() { register_post_type( 'wptests_pt', diff --git a/tests/phpunit/tests/post/meta.php b/tests/phpunit/tests/post/meta.php index 84a8558b7571b..45b0d2cf0caa5 100644 --- a/tests/phpunit/tests/post/meta.php +++ b/tests/phpunit/tests/post/meta.php @@ -44,6 +44,9 @@ public static function wpTearDownAfterClass() { self::delete_user( self::$author ); } + /** + * @covers ::add_post_meta + */ public function test_unique_postmeta() { // Add a unique post meta item. $this->assertIsInt( add_post_meta( self::$post_id, 'unique', 'value', true ) ); @@ -66,6 +69,9 @@ public function test_unique_postmeta() { $this->assertSame( array(), get_post_meta( self::$post_id, 'unique', false ) ); } + /** + * @covers ::add_post_meta + */ public function test_nonunique_postmeta() { // Add two non-unique post meta items. $this->assertIsInt( add_post_meta( self::$post_id, 'nonunique', 'value' ) ); @@ -103,6 +109,9 @@ public function test_nonunique_postmeta() { $this->assertTrue( delete_post_meta_by_key( 'nonunique' ) ); } + /** + * @covers ::update_post_meta + */ public function test_update_post_meta() { // Add a unique post meta item. $this->assertIsInt( add_post_meta( self::$post_id, 'unique_update', 'value', true ) ); @@ -129,6 +138,9 @@ public function test_update_post_meta() { $this->assertSame( array( 'new', 'another new' ), get_post_meta( self::$post_id, 'nonunique_update', false ) ); } + /** + * @covers ::delete_post_meta + */ public function test_delete_post_meta() { // Add two unique post meta items. $this->assertIsInt( add_post_meta( self::$post_id, 'unique_delete', 'value', true ) ); @@ -145,6 +157,9 @@ public function test_delete_post_meta() { $this->assertSame( 'value', get_post_meta( self::$post_id_2, 'unique_delete', true ) ); } + /** + * @covers ::delete_post_meta + */ public function test_delete_post_meta_by_key() { // Add two unique post meta items. $this->assertIsInt( add_post_meta( self::$post_id, 'unique_delete_by_key', 'value', true ) ); @@ -162,6 +177,9 @@ public function test_delete_post_meta_by_key() { $this->assertSame( '', get_post_meta( self::$post_id_2, 'unique_delete_by_key', true ) ); } + /** + * @covers ::get_post_meta_by_id + */ public function test_get_post_meta_by_id() { $mid = add_post_meta( self::$post_id, 'get_post_meta_by_key', 'get_post_meta_by_key_value', true ); $this->assertIsInt( $mid ); @@ -182,6 +200,9 @@ public function test_get_post_meta_by_id() { delete_metadata_by_mid( 'post', $mid ); } + /** + * @covers ::delete_meta + */ public function test_delete_meta() { $mid = add_post_meta( self::$post_id, 'delete_meta', 'delete_meta_value', true ); $this->assertIsInt( $mid ); @@ -192,6 +213,9 @@ public function test_delete_meta() { $this->assertFalse( delete_meta( 123456789 ) ); } + /** + * @covers ::update_meta + */ public function test_update_meta() { // Add a unique post meta item. $mid1 = add_post_meta( self::$post_id, 'unique_update', 'value', true ); @@ -229,6 +253,8 @@ public function test_update_meta() { /** * @ticket 12860 + * + * @covers ::add_post_meta */ public function test_funky_post_meta() { $classy = new StdClass(); @@ -251,6 +277,8 @@ public function test_funky_post_meta() { /** * @ticket 38323 * @dataProvider data_register_post_meta + * + * @covers ::register_post_meta */ public function test_register_post_meta( $post_type, $meta_key, $args ) { add_filter( 'register_meta_args', array( $this, 'filter_register_meta_args_set_last_register_meta_call' ), 10, 4 ); @@ -286,6 +314,8 @@ public function filter_register_meta_args_set_last_register_meta_call( $args, $d /** * @ticket 38323 * @dataProvider data_unregister_post_meta + * + * @covers ::unregister_post_meta */ public function test_unregister_post_meta( $post_type, $meta_key ) { global $wp_meta_keys; @@ -311,6 +341,8 @@ public function data_unregister_post_meta() { /** * @ticket 44467 + * + * @covers ::add_metadata */ public function test_add_metadata_sets_posts_last_changed() { $post_id = self::factory()->post->create(); @@ -323,6 +355,8 @@ public function test_add_metadata_sets_posts_last_changed() { /** * @ticket 44467 + * + * @covers ::update_metadata */ public function test_update_metadata_sets_posts_last_changed() { $post_id = self::factory()->post->create(); @@ -335,6 +369,8 @@ public function test_update_metadata_sets_posts_last_changed() { /** * @ticket 44467 + * + * @covers ::delete_metadata */ public function test_delete_metadata_sets_posts_last_changed() { $post_id = self::factory()->post->create(); diff --git a/tests/phpunit/tests/post/nav-menu.php b/tests/phpunit/tests/post/nav-menu.php index 625d1bc12c22a..624b7013f8c9b 100644 --- a/tests/phpunit/tests/post/nav-menu.php +++ b/tests/phpunit/tests/post/nav-menu.php @@ -61,6 +61,8 @@ public function test_wp_page_menu_wp_nav_menu_fallback() { /** * @ticket 32464 + * + * @covers ::wp_nav_menu */ public function test_wp_nav_menu_empty_container() { $tag_id = self::factory()->tag->create(); @@ -87,6 +89,9 @@ public function test_wp_nav_menu_empty_container() { $this->assertStringStartsWith( 'tag->create(); $cat_id = self::factory()->category->create(); @@ -183,6 +188,8 @@ public function test_wp_get_associated_nav_menu_items() { /** * @ticket 27113 + * + * @covers ::wp_get_nav_menu_items */ public function test_orphan_nav_menu_item() { @@ -216,6 +223,9 @@ public function test_orphan_nav_menu_item() { $this->assertSame( 'WordPress.org', $custom_item->title ); } + /** + * @covers ::wp_get_nav_menu_items + */ public function test_wp_get_nav_menu_items_with_taxonomy_term() { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); @@ -397,6 +407,8 @@ public function test_wp_get_nav_menu_items_cache_primes_terms() { /** * @ticket 13910 + * + * @covers ::wp_get_nav_menu_name */ public function test_wp_get_nav_menu_name() { // Register a nav menu location. @@ -416,6 +428,8 @@ public function test_wp_get_nav_menu_name() { /** * @ticket 29460 + * + * @covers ::wp_get_nav_menus */ public function test_orderby_name_by_default() { // We are going to create a random number of menus (min 2, max 10). @@ -445,6 +459,8 @@ public function test_orderby_name_by_default() { /** * @ticket 35324 + * + * @covers ::wp_setup_nav_menu_item */ public function test_wp_setup_nav_menu_item_for_post_type_archive() { @@ -478,6 +494,8 @@ public function test_wp_setup_nav_menu_item_for_post_type_archive() { /** * @ticket 35324 + * + * @covers ::wp_setup_nav_menu_item */ public function test_wp_setup_nav_menu_item_for_post_type_archive_no_description() { @@ -509,6 +527,8 @@ public function test_wp_setup_nav_menu_item_for_post_type_archive_no_description /** * @ticket 35324 + * + * @covers ::wp_setup_nav_menu_item */ public function test_wp_setup_nav_menu_item_for_post_type_archive_custom_description() { @@ -544,6 +564,8 @@ public function test_wp_setup_nav_menu_item_for_post_type_archive_custom_descrip /** * @ticket 35324 + * + * @covers ::wp_setup_nav_menu_item */ public function test_wp_setup_nav_menu_item_for_unknown_post_type_archive_no_description() { @@ -565,6 +587,8 @@ public function test_wp_setup_nav_menu_item_for_unknown_post_type_archive_no_des /** * @ticket 19038 + * + * @covers ::wp_setup_nav_menu_item */ public function test_wp_setup_nav_menu_item_for_trashed_post() { $post_id = self::factory()->post->create( @@ -615,6 +639,8 @@ public function test_wp_setup_nav_menu_item_short_circuit_filter() { /** * @ticket 35206 + * + * @covers ::wp_nav_menu */ public function test_wp_nav_menu_whitespace_options() { $post_id1 = self::factory()->post->create(); @@ -702,6 +728,8 @@ public function test_wp_nav_menu_whitespace_options() { * backward compatibility. * * @ticket 24587 + * + * @covers ::wp_nav_menu */ public function test_wp_nav_menu_filters_are_passed_args_object() { $tag_id = self::factory()->tag->create(); @@ -788,6 +816,8 @@ public function confirm_forth_param_args_object( $ignored_1, $ignored_2, $ignore /** * @ticket 35272 + * + * @covers ::wp_get_nav_menu_items */ public function test_no_front_page_class_applied() { $page_id = self::factory()->post->create( @@ -819,6 +849,8 @@ public function test_no_front_page_class_applied() { /** * @ticket 35272 + * + * @covers ::wp_get_nav_menu_items */ public function test_class_applied_to_front_page_item() { $page_id = self::factory()->post->create( @@ -852,6 +884,8 @@ public function test_class_applied_to_front_page_item() { /** * @ticket 35272 + * + * @covers ::wp_get_nav_menu_items */ public function test_class_not_applied_to_taxonomies_with_same_id_as_front_page_item() { global $wpdb; @@ -949,6 +983,8 @@ public function test_wp_delete_customize_changeset_dependent_auto_drafts() { /** * @ticket 39800 + * + * @covers ::wp_get_nav_menu_items */ public function test_parent_ancestor_for_post_archive() { @@ -1036,6 +1072,8 @@ public function test_parent_ancestor_for_post_archive() { /** * @ticket 43401 * @dataProvider data_iri_current_menu_item + * + * @covers ::wp_get_nav_menu_items */ public function test_iri_current_menu_item( $custom_link, $current = true ) { wp_update_nav_menu_item( @@ -1079,6 +1117,8 @@ public function data_iri_current_menu_item() { /** * @ticket 44005 * @group privacy + * + * @covers ::wp_get_nav_menu_items */ public function test_no_privacy_policy_class_applied() { $page_id = self::factory()->post->create( @@ -1110,6 +1150,8 @@ public function test_no_privacy_policy_class_applied() { /** * @ticket 44005 * @group privacy + * + * @covers ::wp_get_nav_menu_items */ public function test_class_applied_to_privacy_policy_page_item() { $page_id = self::factory()->post->create( @@ -1144,6 +1186,8 @@ public function test_class_applied_to_privacy_policy_page_item() { /** * @ticket 47723 * @dataProvider data_trim_url_for_custom_item + * + * @covers ::wp_get_nav_menu_items */ public function test_trim_url_for_custom_item( $custom_url, $correct_url ) { $custom_item_id = wp_update_nav_menu_item( @@ -1178,6 +1222,8 @@ public function data_trim_url_for_custom_item() { * be empty, as the item should get the title from the category object itself. * * @ticket 48011 + * + * @covers ::wp_update_nav_menu_item */ public function test_wp_update_nav_menu_item_with_special_characters_in_category_name() { $category_name = 'Test Cat - \"Pre-Slashed\" Cat Name & >'; @@ -1215,6 +1261,8 @@ public function test_wp_update_nav_menu_item_with_special_characters_in_category * of it to ensure that this data is maintained during an import. * * @ticket 52189 + * + * @covers ::wp_update_nav_menu_item */ public function test_wp_update_nav_menu_item_with_post_date() { $post_date = '2020-12-28 11:26:35'; diff --git a/tests/phpunit/tests/post/objects.php b/tests/phpunit/tests/post/objects.php index 01161d09f244c..3daef48911a10 100644 --- a/tests/phpunit/tests/post/objects.php +++ b/tests/phpunit/tests/post/objects.php @@ -5,6 +5,9 @@ */ class Tests_Post_Objects extends WP_UnitTestCase { + /** + * @covers ::get_post + */ public function test_get_post() { $id = self::factory()->post->create(); @@ -66,6 +69,9 @@ public function test_get_post() { $this->assertNull( get_post( false ) ); } + /** + * @covers ::get_post_ancestors + */ public function test_get_post_ancestors() { $parent_id = self::factory()->post->create(); $child_id = self::factory()->post->create(); @@ -100,6 +106,8 @@ public function test_get_post_ancestors() { /** * @ticket 22882 + * + * @covers ::get_post_ancestors */ public function test_get_post_ancestors_with_falsey_values() { foreach ( array( null, 0, false, '0', '' ) as $post_id ) { @@ -108,6 +116,9 @@ public function test_get_post_ancestors_with_falsey_values() { } } + /** + * @covers ::get_post + */ public function test_get_post_category_property() { $post_id = self::factory()->post->create(); $post = get_post( $post_id ); @@ -127,6 +138,9 @@ public function test_get_post_category_property() { $this->assertSame( array( $term2['term_id'], $term3['term_id'], $term1['term_id'] ), $post['post_category'] ); } + /** + * @covers ::get_post + */ public function test_get_tags_input_property() { $post_id = self::factory()->post->create(); $post = get_post( $post_id ); @@ -144,6 +158,9 @@ public function test_get_tags_input_property() { $this->assertSame( array( 'Bar', 'Baz', 'Foo' ), $post['tags_input'] ); } + /** + * @covers ::get_post_meta + */ public function test_get_page_template_property() { $post_id = self::factory()->post->create(); $post = get_post( $post_id ); @@ -157,6 +174,9 @@ public function test_get_page_template_property() { $this->assertSame( $template, $post->page_template ); } + /** + * @covers ::get_post + */ public function test_get_post_filter() { $post = get_post( self::factory()->post->create( @@ -186,6 +206,8 @@ public function test_get_post_filter() { /** * @ticket 53235 + * + * @covers ::get_post */ public function test_numeric_properties_should_be_cast_to_ints() { $post_id = self::factory()->post->create(); @@ -200,6 +222,9 @@ public function test_numeric_properties_should_be_cast_to_ints() { } } + /** + * @covers ::get_post + */ public function test_get_post_identity() { $post = get_post( self::factory()->post->create() ); @@ -209,6 +234,9 @@ public function test_get_post_identity() { $this->assertSame( 'bar', get_post( $post, OBJECT, 'display' )->foo ); } + /** + * @covers ::get_post + */ public function test_get_post_array() { $id = self::factory()->post->create(); @@ -221,6 +249,8 @@ public function test_get_post_array() { /** * @ticket 22223 + * + * @covers ::get_post */ public function test_get_post_cache() { global $wpdb; diff --git a/tests/phpunit/tests/post/output.php b/tests/phpunit/tests/post/output.php index a08f7524eefab..11f3a19b6a2c8 100644 --- a/tests/phpunit/tests/post/output.php +++ b/tests/phpunit/tests/post/output.php @@ -5,6 +5,8 @@ * * @group post * @group formatting + * + * @covers ::the_content */ class Tests_Post_Output extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/post/pings.php b/tests/phpunit/tests/post/pings.php index 899965409ea27..5949133221b1b 100644 --- a/tests/phpunit/tests/post/pings.php +++ b/tests/phpunit/tests/post/pings.php @@ -6,6 +6,9 @@ */ class Tests_Post_Pings extends WP_UnitTestCase { + /** + * @covers ::get_to_ping + */ public function test_returns_to_ping_sites_from_post_id() { $post_id = self::factory()->post->create( array( @@ -16,6 +19,9 @@ public function test_returns_to_ping_sites_from_post_id() { $this->assertSame( array( 'http://www.example.com', 'http://www.otherexample.com' ), get_to_ping( $post_id ) ); } + /** + * @covers ::get_to_ping + */ public function test_returns_to_ping_sites_from_post_object() { $post_id = self::factory()->post->create( array( @@ -27,17 +33,26 @@ public function test_returns_to_ping_sites_from_post_object() { $this->assertSame( array( 'http://www.example.com', 'http://www.otherexample.com' ), get_to_ping( $post ) ); } + /** + * @covers ::get_pung + */ public function test_returns_pinged_sites_from_post_id() { $post_id = self::factory()->post->create( array( 'pinged' => 'foo bar baz' ) ); $this->assertSame( array( 'foo', 'bar', 'baz' ), get_pung( $post_id ) ); } + /** + * @covers ::get_pung + */ public function test_returns_pinged_sites_from_post_object() { $post_id = self::factory()->post->create( array( 'pinged' => 'foo bar baz' ) ); $post = get_post( $post_id ); $this->assertSame( array( 'foo', 'bar', 'baz' ), get_pung( $post ) ); } + /** + * @covers ::get_pung + */ public function test_add_ping_with_post_id() { $post_id = self::factory()->post->create(); add_ping( $post_id, 'foo' ); @@ -46,12 +61,18 @@ public function test_add_ping_with_post_id() { $this->assertSame( array( 'foo', 'bar', 'baz' ), get_pung( $post_id ) ); } + /** + * @covers ::get_pung + */ public function test_add_ping_array_with_post_id() { $post_id = self::factory()->post->create(); add_ping( $post_id, array( 'foo', 'bar', 'baz' ) ); $this->assertSame( array( 'foo', 'bar', 'baz' ), get_pung( $post_id ) ); } + /** + * @covers ::get_pung + */ public function test_add_ping_with_post_object() { $post_id = self::factory()->post->create(); $post = get_post( $post_id ); diff --git a/tests/phpunit/tests/post/postClass.php b/tests/phpunit/tests/post/postClass.php index a3d250eb23f5a..a2c1ecb6d1406 100644 --- a/tests/phpunit/tests/post/postClass.php +++ b/tests/phpunit/tests/post/postClass.php @@ -12,12 +12,18 @@ public function set_up() { $this->post_id = self::factory()->post->create(); } + /** + * @covers ::post_class + */ public function test_post_class() { $expected = 'class="' . implode( ' ', get_post_class( '', $this->post_id ) ) . '"'; $this->expectOutputString( $expected ); post_class( '', $this->post_id ); } + /** + * @covers ::post_class + */ public function test_post_class_extra_esc_attr() { $classes = get_post_class( '', $this->post_id ); $escaped_again = array_map( 'esc_attr', $classes ); diff --git a/tests/phpunit/tests/post/query.php b/tests/phpunit/tests/post/query.php index 9c118cbb9e5f3..84745c3b3ec71 100644 --- a/tests/phpunit/tests/post/query.php +++ b/tests/phpunit/tests/post/query.php @@ -26,6 +26,8 @@ public function tear_down() { /** * @group taxonomy + * + * @covers WP_Query::get */ public function test_category__and_var() { $q = new WP_Query(); @@ -68,6 +70,8 @@ public function test_category__and_var() { /** * @ticket 28099 * @group taxonomy + * + * @covers WP_Query::get */ public function test_empty_category__in() { $cat_id = self::factory()->category->create(); @@ -97,6 +101,8 @@ public function test_empty_category__in() { /** * @ticket 22448 + * + * @covers WP_Query::__construct */ public function test_the_posts_filter() { // Create posts and clear their caches. @@ -147,6 +153,9 @@ public function the_posts_filter( $posts ) { return $posts; } + /** + * @covers WP_Query::__construct + */ public function test_post__in_ordering() { $post_id1 = self::factory()->post->create( array( @@ -195,6 +204,8 @@ public function test_post__in_ordering() { /** * @ticket 38034 + * + * @covers WP_Query::__construct */ public function test_orderby_post__in_array() { $posts = self::factory()->post->create_many( 4 ); @@ -213,6 +224,8 @@ public function test_orderby_post__in_array() { /** * @ticket 38034 + * + * @covers WP_Query::__construct */ public function test_orderby_post__in_array_with_implied_order() { $posts = self::factory()->post->create_many( 4 ); @@ -229,6 +242,9 @@ public function test_orderby_post__in_array_with_implied_order() { $this->assertSame( $ordered, wp_list_pluck( $q->posts, 'ID' ) ); } + /** + * @covers WP_Query::__construct + */ public function test_post__in_attachment_ordering() { $post_id = self::factory()->post->create(); $att_ids = array(); @@ -292,6 +308,8 @@ public function test_post__in_attachment_ordering() { /** * @ticket 36515 + * + * @covers WP_Query::__construct */ public function test_post_name__in_ordering() { $post_id1 = self::factory()->post->create( @@ -327,6 +345,9 @@ public function test_post_name__in_ordering() { $this->assertSame( $ordered, wp_list_pluck( $q->posts, 'post_name' ) ); } + /** + * @covers WP_Query::__construct + */ public function test_post_status() { $statuses1 = get_post_stati(); $this->assertContains( 'auto-draft', $statuses1 ); @@ -349,6 +370,8 @@ public function test_post_status() { /** * @ticket 17065 + * + * @covers WP_Query::__construct */ public function test_orderby_array() { global $wpdb; @@ -385,6 +408,8 @@ public function test_orderby_array() { /** * @ticket 17065 + * + * @covers WP_Query::__construct */ public function test_order() { global $wpdb; @@ -425,6 +450,8 @@ public function test_order() { /** * @ticket 29629 + * + * @covers WP_Query::__construct */ public function test_orderby() { // 'rand' is a valid value. @@ -460,6 +487,8 @@ public function test_orderby() { /** * @ticket 35692 + * + * @covers WP_Query::__construct */ public function test_orderby_rand_with_seed() { $q = new WP_Query( @@ -473,6 +502,8 @@ public function test_orderby_rand_with_seed() { /** * @ticket 35692 + * + * @covers WP_Query::__construct */ public function test_orderby_rand_should_ignore_invalid_seed() { $q = new WP_Query( @@ -486,6 +517,8 @@ public function test_orderby_rand_should_ignore_invalid_seed() { /** * @ticket 35692 + * + * @covers WP_Query::__construct */ public function test_orderby_rand_with_seed_should_be_case_insensitive() { $q = new WP_Query( @@ -501,6 +534,8 @@ public function test_orderby_rand_with_seed_should_be_case_insensitive() { * Tests the post_name__in attribute of WP_Query. * * @ticket 33065 + * + * @covers WP_Query::__construct */ public function test_post_name__in() { $q = new WP_Query(); @@ -553,6 +588,8 @@ public function test_post_name__in() { /** * @ticket 36687 + * + * @covers WP_Query::__construct */ public function test_posts_pre_query_filter_should_bypass_database_query() { add_filter( 'posts_pre_query', array( __CLASS__, 'filter_posts_pre_query' ) ); @@ -577,6 +614,8 @@ public static function filter_posts_pre_query( $posts ) { /** * @ticket 36687 + * + * @covers WP_Query::__construct */ public function test_posts_pre_query_filter_should_respect_set_found_posts() { global $wpdb; @@ -612,6 +651,8 @@ public function filter_found_posts( $posts ) { /** * @ticket 36687 + * + * @covers WP_Query::__construct */ public function test_set_found_posts_fields_ids() { register_post_type( 'wptests_pt' ); @@ -636,6 +677,8 @@ public function test_set_found_posts_fields_ids() { /** * @ticket 36687 + * + * @covers WP_Query::__construct */ public function test_set_found_posts_fields_idparent() { register_post_type( 'wptests_pt' ); @@ -659,6 +702,8 @@ public function test_set_found_posts_fields_idparent() { /** * @ticket 36687 + * + * @covers WP_Query::__construct */ public function test_set_found_posts_fields_split_the_query() { register_post_type( 'wptests_pt' ); @@ -685,6 +730,8 @@ public function test_set_found_posts_fields_split_the_query() { /** * @ticket 36687 + * + * @covers WP_Query::__construct */ public function test_set_found_posts_fields_not_split_the_query() { register_post_type( 'wptests_pt' ); @@ -714,6 +761,8 @@ public function test_set_found_posts_fields_not_split_the_query() { * @ticket 42860 * * @dataProvider data_set_found_posts_not_posts_as_an_array + * + * @covers WP_Query::__construct */ public function test_set_found_posts_not_posts_as_an_array( $posts, $expected ) { $q = new WP_Query( @@ -744,6 +793,8 @@ public function data_set_found_posts_not_posts_as_an_array() { /** * @ticket 42469 + * + * @covers WP_Query::__construct */ public function test_found_posts_should_be_integer_not_string() { $post_id = self::factory()->post->create(); @@ -759,6 +810,8 @@ public function test_found_posts_should_be_integer_not_string() { /** * @ticket 42469 + * + * @covers WP_Query::__construct */ public function test_found_posts_should_be_integer_even_if_found_posts_filter_returns_string_value() { $post_id = self::factory()->post->create(); diff --git a/tests/phpunit/tests/post/revisions.php b/tests/phpunit/tests/post/revisions.php index a4e45aefcf349..5c8d66a8062e8 100644 --- a/tests/phpunit/tests/post/revisions.php +++ b/tests/phpunit/tests/post/revisions.php @@ -23,6 +23,8 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { * * @ticket 20982 * @ticket 16215 + * + * @covers ::wp_restore_post_revision */ public function test_revision_restore_updates_edit_last_post_meta() { // Create a post as Author. @@ -66,6 +68,8 @@ public function test_revision_restore_updates_edit_last_post_meta() { /** * @ticket 7392 * @ticket 9843 + * + * @covers ::wp_update_post */ public function test_revision_dont_save_revision_if_unchanged() { $post = get_default_post_to_edit( 'post', true ); @@ -136,6 +140,8 @@ public function test_revision_dont_save_revision_if_unchanged() { /** * @ticket 7392 * @ticket 9843 + * + * @covers ::wp_update_post */ public function test_revision_force_save_revision_even_if_unchanged() { add_filter( 'wp_save_post_revision_check_for_changes', '__return_false' ); @@ -211,6 +217,8 @@ public function test_revision_force_save_revision_even_if_unchanged() { * Tests the Caps used in the action=view case of wp-admin/revision.php * * @ticket 16847 + * + * @covers ::user_can */ public function test_revision_view_caps_post() { $post_id = self::factory()->post->create( @@ -244,6 +252,8 @@ public function test_revision_view_caps_post() { * Tests the Caps used in the action=restore case of wp-admin/revision.php * * @ticket 16847 + * + * @covers ::user_can */ public function test_revision_restore_caps_post() { $post_id = self::factory()->post->create( @@ -275,6 +285,8 @@ public function test_revision_restore_caps_post() { * Tests the Caps used in the action=diff case of wp-admin/revision.php * * @ticket 16847 + * + * @covers ::user_can */ public function test_revision_diff_caps_post() { $post_id = self::factory()->post->create( @@ -313,6 +325,8 @@ public function test_revision_diff_caps_post() { * Tests the Caps used in the action=view case of wp-admin/revision.php with a CPT with Custom Capabilities * * @ticket 16847 + * + * @covers ::user_can */ public function test_revision_view_caps_cpt() { register_post_type( @@ -355,6 +369,8 @@ public function test_revision_view_caps_cpt() { * Tests the Caps used in the action=restore case of wp-admin/revision.php * * @ticket 16847 + * + * @covers ::user_can */ public function test_revision_restore_caps_cpt() { register_post_type( @@ -401,6 +417,8 @@ public function test_revision_restore_caps_cpt() { * Tests the Caps used in the action=restore case of wp-admin/revision.php * * @ticket 16847 + * + * @covers ::user_can */ public function test_revision_restore_caps_before_publish() { register_post_type( @@ -461,6 +479,8 @@ public function test_revision_restore_caps_before_publish() { * Tests the Caps used in the action=diff case of wp-admin/revision.php * * @ticket 16847 + * + * @covers ::user_can */ public function test_revision_diff_caps_cpt() { register_post_type( @@ -506,6 +526,8 @@ public function test_revision_diff_caps_cpt() { /** * @ticket 26042 + * + * @covers ::wp_get_post_revisions */ public function test_wp_get_post_revisions_should_order_by_post_date() { global $wpdb; @@ -542,6 +564,8 @@ public function test_wp_get_post_revisions_should_order_by_post_date() { /** * @ticket 26042 + * + * @covers ::wp_get_post_revisions */ public function test_wp_get_post_revisions_should_order_by_ID_when_post_date_matches() { $post = self::factory()->post->create_and_get( @@ -577,6 +601,8 @@ public function test_wp_get_post_revisions_should_order_by_ID_when_post_date_mat /** * @ticket 51550 + * + * @covers ::wp_revisions_to_keep */ public function test_wp_revisions_to_keep_filter() { $post = self::factory()->post->create_and_get( @@ -602,6 +628,8 @@ static function () use ( $expected ) { /** * @ticket 51550 + * + * @covers ::wp_revisions_to_keep */ public function test_wp_post_type_revisions_to_keep_filter() { $post = self::factory()->post->create_and_get( @@ -640,6 +668,8 @@ static function () use ( $expected ) { * Verifies that trying to create a revision with an invalid ID returns a WP_Error. * * @ticket 30009 + * + * @covers ::_wp_put_post_revision */ public function test_wp_save_post_revision_error() { $post = self::factory()->post->create_and_get( diff --git a/tests/phpunit/tests/post/slashes.php b/tests/phpunit/tests/post/slashes.php index fdab733f1d7a4..667d562d052e8 100644 --- a/tests/phpunit/tests/post/slashes.php +++ b/tests/phpunit/tests/post/slashes.php @@ -36,6 +36,8 @@ public function set_up() { /** * Tests the controller function that expects slashed data. + * + * @covers ::edit_post */ public function test_edit_post() { $post_id = self::$post_id; @@ -73,6 +75,8 @@ public function test_edit_post() { /** * Tests the model function that expects slashed data. + * + * @covers ::wp_insert_post */ public function test_wp_insert_post() { $post_id = wp_insert_post( @@ -109,6 +113,8 @@ public function test_wp_insert_post() { /** * Tests the model function that expects slashed data. + * + * @covers ::wp_update_post */ public function test_wp_update_post() { $post_id = self::$post_id; @@ -144,6 +150,9 @@ public function test_wp_update_post() { /** * @ticket 27550 + * + * @covers ::wp_trash_post + * @covers ::wp_untrash_post */ public function test_wp_trash_untrash() { $post = array( diff --git a/tests/phpunit/tests/post/thumbnails.php b/tests/phpunit/tests/post/thumbnails.php index fbc8b7bc6e900..7f65d3b4beedb 100644 --- a/tests/phpunit/tests/post/thumbnails.php +++ b/tests/phpunit/tests/post/thumbnails.php @@ -31,6 +31,9 @@ public static function tear_down_after_class() { parent::tear_down_after_class(); } + /** + * @covers ::has_post_thumbnail + */ public function test_has_post_thumbnail() { $this->assertFalse( has_post_thumbnail( self::$post ) ); $this->assertFalse( has_post_thumbnail( self::$post->ID ) ); @@ -53,6 +56,9 @@ public function test_has_post_thumbnail() { $this->assertTrue( has_post_thumbnail() ); } + /** + * @covers ::get_post_thumbnail_id + */ public function test_get_post_thumbnail_id() { $this->assertSame( 0, get_post_thumbnail_id( self::$post ) ); $this->assertSame( 0, get_post_thumbnail_id( self::$post->ID ) ); @@ -68,6 +74,9 @@ public function test_get_post_thumbnail_id() { $this->assertSame( self::$attachment_id, get_post_thumbnail_id() ); } + /** + * @covers ::update_post_thumbnail_cache + */ public function test_update_post_thumbnail_cache() { set_post_thumbnail( self::$post, self::$attachment_id ); @@ -88,6 +97,8 @@ public function test_update_post_thumbnail_cache() { /** * @ticket 12235 + * + * @covers ::get_the_post_thumbnail_caption */ public function test_get_the_post_thumbnail_caption() { $this->assertSame( '', get_the_post_thumbnail_caption() ); @@ -112,6 +123,8 @@ public function test_get_the_post_thumbnail_caption() { /** * @ticket 12235 + * + * @covers ::get_the_post_thumbnail_caption */ public function test_get_the_post_thumbnail_caption_empty() { $post_id = self::factory()->post->create(); @@ -132,6 +145,8 @@ public function test_get_the_post_thumbnail_caption_empty() { /** * @ticket 12235 + * + * @covers ::get_the_post_thumbnail_caption */ public function test_the_post_thumbnail_caption() { $caption = 'This is a caption.'; @@ -153,6 +168,9 @@ public function test_the_post_thumbnail_caption() { the_post_thumbnail_caption( $post_id ); } + /** + * @covers ::get_the_post_thumbnail + */ public function test_get_the_post_thumbnail() { $this->assertSame( '', get_the_post_thumbnail() ); $this->assertSame( '', get_the_post_thumbnail( self::$post ) ); @@ -174,6 +192,9 @@ public function test_get_the_post_thumbnail() { $this->assertSame( $expected, get_the_post_thumbnail() ); } + /** + * @covers ::the_post_thumbnail + */ public function test_the_post_thumbnail() { $this->expectOutputString( '' ); @@ -201,6 +222,8 @@ public function test_the_post_thumbnail() { /** * @ticket 33070 + * + * @covers ::get_the_post_thumbnail_url */ public function test_get_the_post_thumbnail_url() { $this->assertFalse( has_post_thumbnail( self::$post ) ); @@ -219,6 +242,8 @@ public function test_get_the_post_thumbnail_url() { /** * @ticket 33070 + * + * @covers ::get_the_post_thumbnail_url */ public function test_get_the_post_thumbnail_url_with_invalid_post() { set_post_thumbnail( self::$post, self::$attachment_id ); @@ -233,6 +258,8 @@ public function test_get_the_post_thumbnail_url_with_invalid_post() { /** * @ticket 33070 + * + * @covers ::the_post_thumbnail_url */ public function test_the_post_thumbnail_url() { $GLOBALS['post'] = self::$post; @@ -248,6 +275,8 @@ public function test_the_post_thumbnail_url() { /** * @ticket 12922 + * + * @covers ::_wp_preview_post_thumbnail_filter */ public function test__wp_preview_post_thumbnail_filter() { $old_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null; @@ -268,6 +297,8 @@ public function test__wp_preview_post_thumbnail_filter() { /** * @ticket 37697 + * + * @covers ::_wp_preview_post_thumbnail_filter */ public function test__wp_preview_post_thumbnail_filter_secondary_post() { $old_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null; @@ -294,6 +325,8 @@ public function test__wp_preview_post_thumbnail_filter_secondary_post() { /** * @ticket 12922 + * + * @covers ::wp_insert_post */ public function test_insert_post_with_post_thumbnail() { $post_id = wp_insert_post( @@ -325,6 +358,8 @@ public function test_insert_post_with_post_thumbnail() { /** * @ticket 37658 + * + * @covers ::wp_insert_post */ public function test_insert_attachment_with_post_thumbnail() { // Audio files support featured images. @@ -364,6 +399,8 @@ public function test_insert_attachment_with_post_thumbnail() { /** * @ticket 39030 + * + * @covers ::get_the_post_thumbnail */ public function test_post_thumbnail_size_filter_simple() { $this->current_size_filter_data = 'medium'; @@ -385,6 +422,8 @@ public function test_post_thumbnail_size_filter_simple() { /** * @ticket 39030 * @dataProvider data_post_thumbnail_size_filter_complex + * + * @covers ::get_the_post_thumbnail */ public function test_post_thumbnail_size_filter_complex( $which_post, $expected ) { $this->current_size_filter_data = array( diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index df1543fa0c9ca..719d8fc1cd61c 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -24,6 +24,9 @@ public function set_up() { $this->post_type = 'foo1'; } + /** + * @covers ::register_post_type + */ public function test_register_post_type() { $this->assertNull( get_post_type_object( 'foo' ) ); register_post_type( 'foo' ); @@ -41,6 +44,8 @@ public function test_register_post_type() { /** * @ticket 48558 + * + * @covers ::register_post_type */ public function test_register_post_type_return_value() { $this->assertInstanceOf( 'WP_Post_Type', register_post_type( 'foo' ) ); @@ -50,6 +55,8 @@ public function test_register_post_type_return_value() { * @ticket 31134 * * @expectedIncorrectUsage register_post_type + * + * @covers ::register_post_type */ public function test_register_post_type_with_too_long_name() { // Post type too long. @@ -60,6 +67,8 @@ public function test_register_post_type_with_too_long_name() { * @ticket 31134 * * @expectedIncorrectUsage register_post_type + * + * @covers ::register_post_type */ public function test_register_post_type_with_empty_name() { // Post type too short. @@ -68,6 +77,7 @@ public function test_register_post_type_with_empty_name() { /** * @ticket 35985 + * * @covers ::register_post_type */ public function test_register_post_type_exclude_from_search_should_default_to_opposite_value_of_public() { @@ -82,6 +92,7 @@ public function test_register_post_type_exclude_from_search_should_default_to_op /** * @ticket 35985 + * * @covers ::register_post_type */ public function test_register_post_type_publicly_queryable_should_default_to_value_of_public() { @@ -96,6 +107,7 @@ public function test_register_post_type_publicly_queryable_should_default_to_val /** * @ticket 35985 + * * @covers ::register_post_type */ public function test_register_post_type_show_ui_should_default_to_value_of_public() { @@ -110,6 +122,7 @@ public function test_register_post_type_show_ui_should_default_to_value_of_publi /** * @ticket 35985 + * * @covers ::register_post_type */ public function test_register_post_type_show_in_menu_should_default_to_value_of_show_ui() { @@ -129,6 +142,7 @@ public function test_register_post_type_show_in_menu_should_default_to_value_of_ /** * @ticket 35985 + * * @covers ::register_post_type */ public function test_register_post_type_show_in_nav_menus_should_default_to_value_of_public() { @@ -143,6 +157,7 @@ public function test_register_post_type_show_in_nav_menus_should_default_to_valu /** * @ticket 35985 + * * @covers ::register_post_type */ public function test_register_post_type_show_in_admin_bar_should_default_to_value_of_show_in_menu() { @@ -180,6 +195,9 @@ public function test_fires_registered_post_type_actions() { $this->assertSame( 3, $action->get_call_count() ); } + /** + * @covers ::register_taxonomy_for_object_type + */ public function test_register_taxonomy_for_object_type() { global $wp_taxonomies; @@ -202,11 +220,17 @@ public function test_register_taxonomy_for_object_type() { _unregister_post_type( 'bar' ); } + /** + * @covers ::post_type_exists + */ public function test_post_type_exists() { $this->assertFalse( post_type_exists( 'notaposttype' ) ); $this->assertTrue( post_type_exists( 'post' ) ); } + /** + * @covers ::post_type_supports + */ public function test_post_type_supports() { $this->assertTrue( post_type_supports( 'post', 'post-formats' ) ); $this->assertFalse( post_type_supports( 'page', 'post-formats' ) ); @@ -217,6 +241,8 @@ public function test_post_type_supports() { /** * @ticket 21586 + * + * @covers ::post_type_supports */ public function test_post_type_with_no_support() { register_post_type( 'foo', array( 'supports' => array() ) ); @@ -232,6 +258,8 @@ public function test_post_type_with_no_support() { /** * @ticket 23302 + * + * @covers ::register_post_type */ public function test_post_type_with_no_feed() { global $wp_rewrite; @@ -245,6 +273,8 @@ public function test_post_type_with_no_feed() { /** * @ticket 30013 + * + * @covers ::get_post_type_object */ public function test_get_post_type_object_with_non_scalar_values() { $this->assertFalse( post_type_exists( 'foo' ) ); @@ -265,6 +295,8 @@ public function test_get_post_type_object_with_non_scalar_values() { /** * @ticket 33023 + * + * @covers ::get_post_type_object */ public function test_get_post_type_object_casting() { register_post_type( 'foo' ); @@ -282,6 +314,8 @@ public function test_get_post_type_object_casting() { /** * @ticket 38844 + * + * @covers ::get_post_type_object */ public function test_get_post_type_object_includes_menu_icon_for_builtin_post_types() { $this->assertSame( 'dashicons-admin-post', get_post_type_object( 'post' )->menu_icon ); @@ -291,6 +325,8 @@ public function test_get_post_type_object_includes_menu_icon_for_builtin_post_ty /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type() { register_post_type( 'foo' ); @@ -299,6 +335,8 @@ public function test_unregister_post_type() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_unknown_post_type() { $this->assertWPError( unregister_post_type( 'foo' ) ); @@ -306,6 +344,8 @@ public function test_unregister_post_type_unknown_post_type() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_twice() { register_post_type( 'foo' ); @@ -315,6 +355,8 @@ public function test_unregister_post_type_twice() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_disallow_builtin_post_type() { $this->assertWPError( unregister_post_type( 'post' ) ); @@ -326,6 +368,8 @@ public function test_unregister_post_type_disallow_builtin_post_type() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_removes_query_vars() { global $wp; @@ -345,6 +389,8 @@ public function test_unregister_post_type_removes_query_vars() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_removes_rewrite_tags() { $this->set_permalink_structure( '/%postname%' ); @@ -371,6 +417,8 @@ public function test_unregister_post_type_removes_rewrite_tags() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_removes_rewrite_rules() { $this->set_permalink_structure( '/%postname%' ); @@ -392,6 +440,8 @@ public function test_unregister_post_type_removes_rewrite_rules() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_removes_custom_meta_capabilities() { global $post_type_meta_caps; @@ -418,6 +468,8 @@ public function test_unregister_post_type_removes_custom_meta_capabilities() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_removes_post_type_supports() { global $_wp_post_type_features; @@ -444,6 +496,8 @@ public function test_unregister_post_type_removes_post_type_supports() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_removes_post_type_from_taxonomies() { global $wp_taxonomies; @@ -466,6 +520,8 @@ public function test_unregister_post_type_removes_post_type_from_taxonomies() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_removes_the_future_post_hooks() { global $wp_filter; @@ -485,6 +541,8 @@ public function test_unregister_post_type_removes_the_future_post_hooks() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_removes_meta_box_callback() { global $wp_filter; @@ -505,6 +563,8 @@ public function test_unregister_post_type_removes_meta_box_callback() { /** * @ticket 14761 + * + * @covers ::unregister_post_type */ public function test_unregister_post_type_removes_post_type_from_global() { global $wp_post_types; @@ -527,6 +587,9 @@ public function test_unregister_post_type_removes_post_type_from_global() { /** * @ticket 14761 + * + * @covers ::unregister_post_type + * @covers ::post_type_exists */ public function test_post_type_does_not_exist_after_unregister_post_type() { register_post_type( @@ -543,6 +606,8 @@ public function test_post_type_does_not_exist_after_unregister_post_type() { /** * @ticket 34010 + * + * @covers ::get_post_types_by_support */ public function test_get_post_types_by_support_single_feature() { $this->assertContains( 'post', get_post_types_by_support( 'title' ) ); @@ -553,6 +618,8 @@ public function test_get_post_types_by_support_single_feature() { /** * @ticket 34010 + * + * @covers ::get_post_types_by_support */ public function test_get_post_types_by_support_multiple_features() { $this->assertContains( 'post', get_post_types_by_support( array( 'thumbnail', 'author' ) ) ); @@ -561,6 +628,8 @@ public function test_get_post_types_by_support_multiple_features() { /** * @ticket 34010 + * + * @covers ::get_post_types_by_support */ public function test_get_post_types_by_support_or_operator() { $this->assertContains( 'post', get_post_types_by_support( array( 'post-formats', 'page-attributes' ), 'or' ) ); @@ -569,6 +638,8 @@ public function test_get_post_types_by_support_or_operator() { /** * @ticket 34010 + * + * @covers ::get_post_types_by_support */ public function test_get_post_types_by_support_not_operator() { $this->assertContains( 'attachment', get_post_types_by_support( array( 'thumbnail' ), 'not' ) ); @@ -578,6 +649,8 @@ public function test_get_post_types_by_support_not_operator() { /** * @ticket 34010 + * + * @covers ::get_post_types_by_support */ public function test_get_post_types_by_support_excluding_features() { $this->assertSameSets( array(), get_post_types_by_support( array( 'post-formats', 'page-attributes' ) ) ); @@ -585,6 +658,8 @@ public function test_get_post_types_by_support_excluding_features() { /** * @ticket 34010 + * + * @covers ::get_post_types_by_support */ public function test_get_post_types_by_support_non_existant_feature() { $this->assertSameSets( array(), get_post_types_by_support( 'somefeature' ) ); diff --git a/tests/phpunit/tests/post/walkerPage.php b/tests/phpunit/tests/post/walkerPage.php index d8a2312a54eff..18a9d020c74a8 100644 --- a/tests/phpunit/tests/post/walkerPage.php +++ b/tests/phpunit/tests/post/walkerPage.php @@ -25,6 +25,8 @@ public function set_up() { * @ticket 47720 * * @dataProvider data_start_el_with_empty_attributes + * + * @covers Walker_Page::start_el */ public function test_start_el_with_empty_attributes( $value, $expected ) { $output = ''; diff --git a/tests/phpunit/tests/post/wpAfterInsertPost.php b/tests/phpunit/tests/post/wpAfterInsertPost.php index f184c66e01288..973ba75ecf108 100644 --- a/tests/phpunit/tests/post/wpAfterInsertPost.php +++ b/tests/phpunit/tests/post/wpAfterInsertPost.php @@ -121,6 +121,8 @@ public function action_wp_after_insert_post( $post_id, $post, $update, $post_bef * Ensure before post is correct when updating a post object. * * @ticket 45114 + * + * @covers ::wp_update_post */ public function test_update_via_wp_update_post() { $post = get_post( self::$post_id, ARRAY_A ); @@ -135,6 +137,8 @@ public function test_update_via_wp_update_post() { * Ensure before post is correct when publishing a post object. * * @ticket 45114 + * + * @covers ::wp_publish_post */ public function test_update_via_wp_publish_post() { wp_publish_post( self::$post_id ); @@ -147,6 +151,8 @@ public function test_update_via_wp_publish_post() { * Ensure before post is correct when inserting a new post. * * @ticket 45114 + * + * @covers ::wp_insert_post */ public function test_new_post_via_wp_insert_post() { wp_insert_post( @@ -165,6 +171,8 @@ public function test_new_post_via_wp_insert_post() { * Ensure before post is correct when updating post via REST API. * * @ticket 45114 + * + * @covers ::wp_update_post */ public function test_update_via_rest_contoller() { wp_set_current_user( self::$admin_id ); @@ -183,6 +191,8 @@ public function test_update_via_rest_contoller() { * Ensure before post is correct when creating post via REST API. * * @ticket 45114 + * + * @covers ::wp_insert_post */ public function test_new_post_via_rest_contoller() { wp_set_current_user( self::$admin_id ); @@ -205,6 +215,8 @@ public function test_new_post_via_rest_contoller() { * Ensure before post is correct when updating post via REST API. * * @ticket 45114 + * + * @covers ::wp_update_post */ public function test_update_attachment_via_rest_contoller() { wp_set_current_user( self::$admin_id ); diff --git a/tests/phpunit/tests/post/wpGetPostParentId.php b/tests/phpunit/tests/post/wpGetPostParentId.php index c2160498bc8fc..49fcabe031f43 100644 --- a/tests/phpunit/tests/post/wpGetPostParentId.php +++ b/tests/phpunit/tests/post/wpGetPostParentId.php @@ -23,12 +23,18 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { self::$post_id = $factory->post->create( array( 'post_parent' => self::$parent_post_id ) ); } + /** + * @covers ::wp_get_post_parent_id + */ public function test_wp_get_post_parent_id_with_post_object() { $post = get_post( self::$post_id ); $this->assertInstanceOf( 'WP_Post', $post ); $this->assertSame( self::$parent_post_id, wp_get_post_parent_id( $post ) ); } + /** + * @covers ::wp_get_post_parent_id + */ public function test_wp_get_post_parent_id_with_post_id() { $this->assertSame( self::$parent_post_id, wp_get_post_parent_id( self::$post_id ) ); } @@ -42,16 +48,25 @@ public function test_wp_get_post_parent_id_with_no_post_argument_default_to_glob $this->assertSame( self::$parent_post_id, wp_get_post_parent_id() ); } + /** + * @covers ::wp_get_post_parent_id + */ public function test_wp_get_post_parent_id_with_non_existing_id_default_to_global_post_id() { $GLOBALS['post'] = get_post( self::$post_id ); $this->assertSame( self::$parent_post_id, wp_get_post_parent_id( 0 ) ); } + /** + * @covers ::wp_get_post_parent_id + */ public function test_wp_get_post_parent_id_with_boolean_default_to_global_post_id() { $GLOBALS['post'] = get_post( self::$post_id ); $this->assertSame( self::$parent_post_id, wp_get_post_parent_id( false ) ); } + /** + * @covers ::wp_get_post_parent_id + */ public function test_wp_get_post_parent_id_with_string_default_to_false() { $GLOBALS['post'] = get_post( self::$post_id ); $this->assertFalse( wp_get_post_parent_id( 'string' ) ); diff --git a/tests/phpunit/tests/post/wpInsertPost.php b/tests/phpunit/tests/post/wpInsertPost.php index 1b0838cf06fd5..4a79f46f5994f 100644 --- a/tests/phpunit/tests/post/wpInsertPost.php +++ b/tests/phpunit/tests/post/wpInsertPost.php @@ -1240,6 +1240,8 @@ public function test_insert_invalid_post_date() { /** * @ticket 11863 + * + * @covers ::wp_trash_post */ public function test_trashing_a_post_should_add_trashed_suffix_to_post_name() { $trashed_about_page_id = self::factory()->post->create( @@ -1255,6 +1257,8 @@ public function test_trashing_a_post_should_add_trashed_suffix_to_post_name() { /** * @ticket 11863 + * + * @covers ::wp_trash_post */ public function test_trashed_suffix_should_be_added_to_post_with__trashed_in_slug() { $trashed_about_page_id = self::factory()->post->create( @@ -1271,6 +1275,8 @@ public function test_trashed_suffix_should_be_added_to_post_with__trashed_in_slu /** * @ticket 11863 + * + * @covers ::wp_untrash_post */ public function test_trashed_posts_original_post_name_should_be_reassigned_after_untrashing() { $about_page_id = self::factory()->post->create( @@ -1288,6 +1294,8 @@ public function test_trashed_posts_original_post_name_should_be_reassigned_after /** * @ticket 11863 + * + * @covers ::wp_insert_post */ public function test_creating_a_new_post_should_add_trashed_suffix_to_post_name_of_trashed_posts_with_the_desired_slug() { $trashed_about_page_id = self::factory()->post->create( @@ -1312,6 +1320,8 @@ public function test_creating_a_new_post_should_add_trashed_suffix_to_post_name_ /** * @ticket 11863 + * + * @covers ::wp_untrash_post */ public function test_untrashing_a_post_with_a_stored_desired_post_name_should_get_its_post_name_suffixed_if_another_post_has_taken_the_desired_post_name() { $about_page_id = self::factory()->post->create( @@ -1346,6 +1356,8 @@ public function test_untrashing_a_post_with_a_stored_desired_post_name_should_ge /** * @ticket 23022 * @dataProvider data_various_post_statuses + * + * @covers ::wp_untrash_post */ public function test_untrashing_a_post_should_always_restore_it_to_draft_status( $post_status ) { $page_id = self::factory()->post->create( @@ -1364,6 +1376,8 @@ public function test_untrashing_a_post_should_always_restore_it_to_draft_status( /** * @ticket 23022 * @dataProvider data_various_post_statuses + * + * @covers ::wp_untrash_post */ public function test_wp_untrash_post_status_filter_restores_post_to_correct_status( $post_status ) { add_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status', 10, 3 ); @@ -1419,6 +1433,9 @@ public function data_various_post_statuses() { * * @ticket 42464 * @dataProvider data_various_post_types + * + * @covers ::wp_insert_post + * @covers ::wp_update_post */ public function test_contributor_cannot_set_post_slug( $post_type ) { wp_set_current_user( self::$user_ids['contributor'] ); @@ -1458,6 +1475,9 @@ public function test_contributor_cannot_set_post_slug( $post_type ) { * * @ticket 42464 * @dataProvider data_various_post_types + * + * @covers ::wp_insert_post + * @covers ::wp_update_post */ public function test_administrator_can_set_post_slug( $post_type ) { wp_set_current_user( self::$user_ids['administrator'] ); @@ -1499,6 +1519,9 @@ public function test_administrator_can_set_post_slug( $post_type ) { * These assertions failed prior to ticket #42464. * * @ticket 42464 + * + * @covers ::wp_insert_post + * @covers ::wp_update_post */ public function test_administrator_cannot_set_post_slug_on_post_type_they_cannot_publish() { wp_set_current_user( self::$user_ids['administrator'] ); @@ -1535,6 +1558,8 @@ public function test_administrator_cannot_set_post_slug_on_post_type_they_cannot /** * @ticket 25347 + * + * @covers ::wp_insert_post */ public function test_scheduled_post_with_a_past_date_should_be_published() { diff --git a/tests/phpunit/tests/post/wpListPages.php b/tests/phpunit/tests/post/wpListPages.php index 38ba729cee20b..90a94cfcdd1cb 100644 --- a/tests/phpunit/tests/post/wpListPages.php +++ b/tests/phpunit/tests/post/wpListPages.php @@ -2,6 +2,8 @@ /** * @group post + * + * @covers ::wp_list_pages */ class Tests_Post_wpListPages extends WP_UnitTestCase { /** @@ -387,7 +389,6 @@ public function test_wp_list_pages_link_after() { $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } - public function test_wp_list_pages_include() { $args = array( 'echo' => false, diff --git a/tests/phpunit/tests/post/wpPost.php b/tests/phpunit/tests/post/wpPost.php index 58a7f758e7946..02963aa128872 100644 --- a/tests/phpunit/tests/post/wpPost.php +++ b/tests/phpunit/tests/post/wpPost.php @@ -2,6 +2,8 @@ /** * @group post + * + * @covers WP_Post::get_instance */ class Tests_Post_wpPost extends WP_UnitTestCase { protected static $post_id; diff --git a/tests/phpunit/tests/post/wpPostType.php b/tests/phpunit/tests/post/wpPostType.php index 2a8ad42f0a2ca..6d51ad65ffeaf 100644 --- a/tests/phpunit/tests/post/wpPostType.php +++ b/tests/phpunit/tests/post/wpPostType.php @@ -12,6 +12,10 @@ public function test_instances() { } } + /** + * @covers WP_Post_Type::add_supports + * @covers WP_Post_Type::remove_supports + */ public function test_add_supports_defaults() { $post_type = 'cpt'; $post_type_object = new WP_Post_Type( $post_type ); @@ -32,6 +36,10 @@ public function test_add_supports_defaults() { $this->assertSameSets( array(), $post_type_supports_after ); } + /** + * @covers WP_Post_Type::add_supports + * @covers WP_Post_Type::remove_supports + */ public function test_add_supports_custom() { $post_type = 'cpt'; $post_type_object = new WP_Post_Type( @@ -66,6 +74,9 @@ public function test_add_supports_custom() { * Test that supports can optionally receive nested args. * * @ticket 40413 + * + * @covers WP_Post_Type::add_supports + * @covers WP_Post_Type::remove_supports */ public function test_add_supports_custom_with_args() { $post_type = 'cpt'; @@ -103,6 +114,10 @@ public function test_add_supports_custom_with_args() { $this->assertSameSets( array(), $post_type_supports_after ); } + /** + * @covers WP_Post_Type::__construct + * @covers WP_Post_Type::add_rewrite_rules + */ public function test_does_not_add_query_var_if_not_public() { $this->set_permalink_structure( '/%postname%' ); @@ -122,6 +137,10 @@ public function test_does_not_add_query_var_if_not_public() { $this->assertNotContains( 'foobar', $wp->public_query_vars ); } + /** + * @covers WP_Post_Type::__construct + * @covers WP_Post_Type::add_rewrite_rules + */ public function test_adds_query_var_if_public() { $this->set_permalink_structure( '/%postname%' ); @@ -148,6 +167,10 @@ public function test_adds_query_var_if_public() { $this->assertFalse( $in_array_after ); } + /** + * @covers WP_Post_Type::add_rewrite_rules + * @covers WP_Post_Type::remove_rewrite_rules + */ public function test_adds_rewrite_rules() { $this->set_permalink_structure( '/%postname%' ); @@ -173,6 +196,10 @@ public function test_adds_rewrite_rules() { $this->assertFalse( array_search( "%$post_type%", $rewrite_tags_after, true ) ); } + /** + * @covers WP_Post_Type::register_meta_boxes + * @covers WP_Post_Type::unregister_meta_boxes + */ public function test_register_meta_boxes() { $post_type = 'cpt'; $post_type_object = new WP_Post_Type( $post_type, array( 'register_meta_box_cb' => '__return_false' ) ); @@ -186,6 +213,10 @@ public function test_register_meta_boxes() { $this->assertFalse( $has_action_after ); } + /** + * @covers WP_Post_Type::add_hooks + * @covers WP_Post_Type::remove_hooks + */ public function test_adds_future_post_hook() { $post_type = 'cpt'; $post_type_object = new WP_Post_Type( $post_type ); @@ -198,6 +229,10 @@ public function test_adds_future_post_hook() { $this->assertFalse( $has_action_after ); } + /** + * @covers WP_Post_Type::register_taxonomies + * @covers WP_Post_Type::unregister_taxonomies + */ public function test_register_taxonomies() { global $wp_post_types; diff --git a/tests/phpunit/tests/post/wpPublishPost.php b/tests/phpunit/tests/post/wpPublishPost.php index 25fa87a71c91d..250fb0ec72802 100644 --- a/tests/phpunit/tests/post/wpPublishPost.php +++ b/tests/phpunit/tests/post/wpPublishPost.php @@ -139,6 +139,8 @@ public function test_wp_publish_post_and_avoid_content_filtering() { * Ensure wp_publish_post does not add default category in error. * * @ticket 51292 + * + * @covers ::wp_publish_post */ public function test_wp_publish_post_respects_current_categories() { $post_id = self::$auto_draft_id; @@ -157,9 +159,9 @@ public function test_wp_publish_post_respects_current_categories() { /** * Ensure wp_publish_post adds default category. + * @ticket 51292 * * @covers ::wp_publish_post - * @ticket 51292 */ public function test_wp_publish_post_adds_default_category() { $post_id = self::$auto_draft_id; @@ -177,9 +179,9 @@ public function test_wp_publish_post_adds_default_category() { /** * Ensure wp_publish_post adds default category when tagged. + * @ticket 51292 * * @covers ::wp_publish_post - * @ticket 51292 */ public function test_wp_publish_post_adds_default_category_when_tagged() { $post_id = self::$auto_draft_id; @@ -198,9 +200,9 @@ public function test_wp_publish_post_adds_default_category_when_tagged() { /** * Ensure wp_publish_post does not add default term in error. + * @ticket 51292 * * @covers ::wp_publish_post - * @ticket 51292 */ public function test_wp_publish_post_respects_current_terms() { // Create custom taxonomy to test with. @@ -233,9 +235,9 @@ public function test_wp_publish_post_respects_current_terms() { /** * Ensure wp_publish_post adds default term. + * @ticket 51292 * * @covers ::wp_publish_post - * @ticket 51292 */ public function test_wp_publish_post_adds_default_term() { // Create custom taxonomy to test with. diff --git a/tests/phpunit/tests/post/wpUniquePostSlug.php b/tests/phpunit/tests/post/wpUniquePostSlug.php index f242159987e3f..56390550bfcd9 100644 --- a/tests/phpunit/tests/post/wpUniquePostSlug.php +++ b/tests/phpunit/tests/post/wpUniquePostSlug.php @@ -8,6 +8,8 @@ class Tests_Post_wpUniquePostSlug extends WP_UnitTestCase { /** * @ticket 21013 + * + * @covers ::wp_insert_post */ public function test_non_latin_slugs() { $author_id = self::factory()->user->create( array( 'role' => 'editor' ) ); @@ -42,6 +44,8 @@ public function test_non_latin_slugs() { /** * @ticket 18962 + * + * @covers ::wp_unique_post_slug */ public function test_with_multiple_hierarchies() { register_post_type( 'post-type-1', array( 'hierarchical' => true ) ); @@ -68,6 +72,8 @@ public function test_with_multiple_hierarchies() { /** * @ticket 30339 + * + * @covers ::wp_unique_post_slug */ public function test_with_hierarchy() { register_post_type( 'post-type-1', array( 'hierarchical' => true ) ); @@ -91,6 +97,8 @@ public function test_with_hierarchy() { /** * @ticket 18962 + * + * @covers ::wp_unique_post_slug */ public function test_wp_unique_post_slug_with_hierarchy_and_attachments() { register_post_type( 'post-type-1', array( 'hierarchical' => true ) ); @@ -129,6 +137,8 @@ public function test_wp_unique_post_slug_with_hierarchy_and_attachments() { /** * @dataProvider data_allowed_post_statuses_should_not_be_forced_to_be_unique + * + * @covers ::wp_unique_post_slug */ public function test_allowed_post_statuses_should_not_be_forced_to_be_unique( $status ) { $p1 = self::factory()->post->create( @@ -157,6 +167,9 @@ public function data_allowed_post_statuses_should_not_be_forced_to_be_unique() { ); } + /** + * @covers ::wp_unique_post_slug + */ public function test_revisions_should_not_be_forced_to_be_unique() { $p1 = self::factory()->post->create( array( @@ -178,6 +191,8 @@ public function test_revisions_should_not_be_forced_to_be_unique() { /** * @ticket 5305 + * + * @covers ::wp_unique_post_slug */ public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_be_suffixed() { $this->set_permalink_structure( '/%postname%/' ); @@ -195,6 +210,8 @@ public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_s /** * @ticket 5305 + * + * @covers ::wp_unique_post_slug */ public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_not_be_suffixed_for_already_published_posts() { $this->set_permalink_structure( '/%postname%/' ); @@ -213,6 +230,8 @@ public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_s /** * @ticket 5305 + * + * @covers ::wp_unique_post_slug */ public function test_yearlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_year_archives() { $this->set_permalink_structure( '/%year%/%postname%/' ); @@ -230,6 +249,8 @@ public function test_yearlike_slugs_should_not_be_suffixed_if_permalink_structur /** * @ticket 5305 + * + * @covers ::wp_unique_post_slug */ public function test_slugs_resulting_in_permalinks_that_resemble_month_archives_should_be_suffixed() { $this->set_permalink_structure( '/%year%/%postname%/' ); @@ -247,6 +268,8 @@ public function test_slugs_resulting_in_permalinks_that_resemble_month_archives_ /** * @ticket 5305 + * + * @covers ::wp_unique_post_slug */ public function test_monthlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_month_archives() { $this->set_permalink_structure( '/%year%/foo/%postname%/' ); @@ -264,6 +287,8 @@ public function test_monthlike_slugs_should_not_be_suffixed_if_permalink_structu /** * @ticket 5305 + * + * @covers ::wp_unique_post_slug */ public function test_monthlike_slugs_should_not_be_suffixed_for_invalid_month_numbers() { $this->set_permalink_structure( '/%year%/%postname%/' ); @@ -281,6 +306,8 @@ public function test_monthlike_slugs_should_not_be_suffixed_for_invalid_month_nu /** * @ticket 5305 + * + * @covers ::wp_unique_post_slug */ public function test_slugs_resulting_in_permalinks_that_resemble_day_archives_should_be_suffixed() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); @@ -298,6 +325,8 @@ public function test_slugs_resulting_in_permalinks_that_resemble_day_archives_sh /** * @ticket 5305 + * + * @covers ::wp_unique_post_slug */ public function test_daylike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_day_archives() { $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); @@ -315,6 +344,8 @@ public function test_daylike_slugs_should_not_be_suffixed_if_permalink_structure /** * @ticket 5305 + * + * @covers ::wp_unique_post_slug */ public function test_daylike_slugs_should_not_be_suffixed_for_invalid_day_numbers() { $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); @@ -332,6 +363,8 @@ public function test_daylike_slugs_should_not_be_suffixed_for_invalid_day_number /** * @ticket 34971 + * + * @covers ::wp_unique_post_slug */ public function test_embed_slug_should_be_suffixed_for_posts() { $this->set_permalink_structure( '/%postname%/' ); @@ -349,6 +382,8 @@ public function test_embed_slug_should_be_suffixed_for_posts() { /** * @ticket 34971 + * + * @covers ::wp_unique_post_slug */ public function test_embed_slug_should_be_suffixed_for_pages() { $this->set_permalink_structure( '/%postname%/' ); @@ -366,6 +401,8 @@ public function test_embed_slug_should_be_suffixed_for_pages() { /** * @ticket 34971 + * + * @covers ::wp_unique_post_slug */ public function test_embed_slug_should_be_suffixed_for_attachments() { $this->set_permalink_structure( '/%postname%/' ); diff --git a/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php b/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php index 840f756344f14..cdbf6469a5275 100644 --- a/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php +++ b/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php @@ -9,6 +9,8 @@ * @group privacy * @covers ::wp_privacy_generate_personal_data_export_file * @requires extension zip + * + * @covers ::wp_privacy_generate_personal_data_export_file */ class Tests_Privacy_wpPrivacyGeneratePersonalDataExportFile extends WP_UnitTestCase { /**