|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * @group admin |
| 5 | + * @group privacy |
| 6 | + * |
| 7 | + * @covers ::_wp_privacy_settings_filter_draft_page_titles |
| 8 | + */ |
| 9 | +class Tests_Admin_Includes_Misc_WpPrivacySettingsFilterDraftPageTitles_Test extends WP_UnitTestCase { |
| 10 | + |
| 11 | + /** |
| 12 | + * Tests that _wp_privacy_settings_filter_draft_page_titles() appends '(Draft)' when appropriate. |
| 13 | + * |
| 14 | + * @ticket 65202 |
| 15 | + * |
| 16 | + * @dataProvider data_wp_privacy_settings_filter_draft_page_titles |
| 17 | + * |
| 18 | + * @param string $expected The expected title. |
| 19 | + * @param string $title The input title. |
| 20 | + * @param string $post_status The post status. |
| 21 | + * @param string $screen_id The current screen ID. |
| 22 | + */ |
| 23 | + public function test_wp_privacy_settings_filter_draft_page_titles( $expected, $title, $post_status, $screen_id ) { |
| 24 | + set_current_screen( $screen_id ); |
| 25 | + |
| 26 | + $page = self::factory()->post->create_and_get( array( 'post_status' => $post_status ) ); |
| 27 | + |
| 28 | + $actual = _wp_privacy_settings_filter_draft_page_titles( $title, $page ); |
| 29 | + |
| 30 | + $this->assertSame( $expected, $actual ); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Data provider for test_wp_privacy_settings_filter_draft_page_titles(). |
| 35 | + * |
| 36 | + * @return array<string, array{ |
| 37 | + * expected: string, |
| 38 | + * title: string, |
| 39 | + * post_status: string, |
| 40 | + * screen_id: string, |
| 41 | + * }> |
| 42 | + */ |
| 43 | + public function data_wp_privacy_settings_filter_draft_page_titles(): array { |
| 44 | + return array( |
| 45 | + 'draft page on privacy screen' => array( |
| 46 | + 'expected' => 'Privacy Policy (Draft)', |
| 47 | + 'title' => 'Privacy Policy', |
| 48 | + 'post_status' => 'draft', |
| 49 | + 'screen_id' => 'privacy', |
| 50 | + ), |
| 51 | + 'published page on privacy screen' => array( |
| 52 | + 'expected' => 'Privacy Policy', |
| 53 | + 'title' => 'Privacy Policy', |
| 54 | + 'post_status' => 'publish', |
| 55 | + 'screen_id' => 'privacy', |
| 56 | + ), |
| 57 | + 'draft page on other screen' => array( |
| 58 | + 'expected' => 'About Us', |
| 59 | + 'title' => 'About Us', |
| 60 | + 'post_status' => 'draft', |
| 61 | + 'screen_id' => 'edit-page', |
| 62 | + ), |
| 63 | + 'pending page on privacy screen' => array( |
| 64 | + 'expected' => 'Privacy Policy', |
| 65 | + 'title' => 'Privacy Policy', |
| 66 | + 'post_status' => 'pending', |
| 67 | + 'screen_id' => 'privacy', |
| 68 | + ), |
| 69 | + ); |
| 70 | + } |
| 71 | +} |
0 commit comments