Repository navigation
General: Show the week in the title of weekly archives. #15510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Tests for the `get_the_archive_title()` function on date archives. | ||
| * | ||
| * @group general | ||
| * @group template | ||
| * | ||
| * @covers ::get_the_archive_title | ||
| */ | ||
| class Tests_General_GetTheArchiveTitle extends WP_UnitTestCase { | ||
|
|
||
| public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { | ||
| $factory->post->create( | ||
| array( | ||
| 'post_status' => 'publish', | ||
| 'post_date' => '2015-09-22 18:52:17', | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| public function set_up() { | ||
| parent::set_up(); | ||
|
|
||
| update_option( 'start_of_week', 1 ); | ||
| update_option( 'date_format', 'F j, Y' ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that a weekly archive uses the week's date range, not the year. | ||
| * | ||
| * @ticket 66489 | ||
| */ | ||
| public function test_get_the_archive_title_on_weekly_archive() { | ||
| $this->go_to( '?m=2015&w=39' ); | ||
|
|
||
| $this->assertTrue( is_year(), 'Weekly archive links also set is_year().' ); | ||
| $this->assertSame( 'Week: <span>September 21, 2015 – September 27, 2015</span>', get_the_archive_title() ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that a weekly archive respects the start_of_week option. | ||
| * | ||
| * @ticket 66489 | ||
| */ | ||
| public function test_get_the_archive_title_on_weekly_archive_respects_start_of_week() { | ||
| update_option( 'start_of_week', 0 ); | ||
|
|
||
| $this->go_to( '?m=2015&w=38' ); | ||
|
|
||
| $this->assertSame( 'Week: <span>September 20, 2015 – September 26, 2015</span>', get_the_archive_title() ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that a weekly archive without the year uses the week's date range. | ||
| * | ||
| * @ticket 66489 | ||
| */ | ||
| public function test_get_the_archive_title_on_weekly_archive_without_year() { | ||
| $this->go_to( '?w=39' ); | ||
|
|
||
| $this->assertSame( 'Week: <span>September 21, 2015 – September 27, 2015</span>', get_the_archive_title() ); | ||
| } | ||
|
|
||
| /** | ||
| * @ticket 66489 | ||
| */ | ||
| public function test_get_the_archive_title_on_yearly_archive() { | ||
| $this->go_to( '?m=2015' ); | ||
|
|
||
| $this->assertSame( 'Year: <span>2015</span>', get_the_archive_title() ); | ||
| } | ||
|
|
||
| /** | ||
| * @ticket 66489 | ||
| */ | ||
| public function test_get_the_archive_title_on_monthly_archive() { | ||
| $this->go_to( '?m=201509' ); | ||
|
|
||
| $this->assertSame( 'Month: <span>September 2015</span>', get_the_archive_title() ); | ||
| } | ||
|
|
||
| /** | ||
| * @ticket 66489 | ||
| */ | ||
| public function test_get_the_archive_title_on_daily_archive() { | ||
| $this->go_to( '?m=20150922' ); | ||
|
|
||
| $this->assertSame( 'Day: <span>September 22, 2015</span>', get_the_archive_title() ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -240,6 +240,28 @@ public function test_day_title() { | |||||||
| $this->assertSame( sprintf( 'September 22, 2015 – %s', $this->blog_name ), wp_get_document_title() ); | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * @ticket 66489 | ||||||||
| */ | ||||||||
|
Comment on lines
+243
to
+245
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this comment/doc is not necessary (it's not used in the rest of the file).
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I'd prefer to keep it: per the Core handbook, |
||||||||
| public function test_week_title() { | ||||||||
| update_option( 'start_of_week', 1 ); | ||||||||
|
|
||||||||
| $this->go_to( '?m=2015&w=39' ); | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also test a URL like this:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added test_week_title_without_year in c059a75. |
||||||||
|
|
||||||||
| $this->assertSame( sprintf( 'September 21, 2015 – September 27, 2015 – %s', $this->blog_name ), wp_get_document_title() ); | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * @ticket 66489 | ||||||||
| */ | ||||||||
| public function test_week_title_without_year() { | ||||||||
| update_option( 'start_of_week', 1 ); | ||||||||
|
|
||||||||
| $this->go_to( '?w=39' ); | ||||||||
|
|
||||||||
| $this->assertSame( sprintf( 'September 21, 2015 – September 27, 2015 – %s', $this->blog_name ), wp_get_document_title() ); | ||||||||
| } | ||||||||
|
|
||||||||
| public function test_404_title() { | ||||||||
| $this->go_to( '?m=404' ); | ||||||||
|
|
||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string has to be translated for the different language packs when these changes are merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks