Skip to content

Commit b3a6174

Browse files
Merge pull request #7 from pantheon-systems/test-date-archives
Add explicit tests for date archives
2 parents 5134ff2 + 2499417 commit b3a6174

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

tests/class-pantheon-integrated-cdn-testcase.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,23 @@ public function setUp() {
1616
$this->category_id2 = $this->factory->category->create();
1717

1818
$this->post_id1 = $this->factory->post->create( array(
19-
'post_status' => 'publish',
20-
'post_author' => $this->user_id1,
19+
'post_status' => 'publish',
20+
'post_author' => $this->user_id1,
21+
'post_date' => '2016-10-14 12:00',
22+
'post_date_gmt' => '2016-10-14 12:00',
2123
) );
2224
wp_set_object_terms( $this->post_id1, array( $this->tag_id2 ), 'post_tag' );
2325
$this->post_id2 = $this->factory->post->create( array(
24-
'post_status' => 'publish',
25-
'post_author' => $this->user_id2,
26+
'post_status' => 'publish',
27+
'post_author' => $this->user_id2,
28+
'post_date' => '2016-10-14 11:00',
29+
'post_date_gmt' => '2016-10-14 11:00',
30+
) );
31+
$this->post_id3 = $this->factory->post->create( array(
32+
'post_status' => 'publish',
33+
'post_author' => $this->user_id2,
34+
'post_date' => '2016-10-15 11:00',
35+
'post_date_gmt' => '2016-10-15 11:00',
2636
) );
2737
$this->page_id1 = $this->factory->post->create( array(
2838
'post_status' => 'publish',

tests/test-emitter.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public function test_homepage_default() {
1111
'home',
1212
'post-' . $this->post_id1,
1313
'post-' . $this->post_id2,
14+
'post-' . $this->post_id3,
1415
'user-' . $this->user_id1,
1516
'user-' . $this->user_id2,
1617
), Emitter::get_surrogate_keys() );
@@ -69,6 +70,57 @@ public function test_single_tag_without_posts() {
6970
), Emitter::get_surrogate_keys() );
7071
}
7172

73+
public function test_year_date_archive_with_posts() {
74+
$this->go_to( home_url( '?year=2016' ) );
75+
$this->assertArrayValues( array(
76+
'archive',
77+
'date',
78+
'post-' . $this->post_id1,
79+
'post-' . $this->post_id2,
80+
'post-' . $this->post_id3,
81+
'user-' . $this->user_id1,
82+
'user-' . $this->user_id2,
83+
), Emitter::get_surrogate_keys() );
84+
}
85+
86+
public function test_year_date_archive_without_posts() {
87+
$this->go_to( home_url( '?year=2015' ) );
88+
$this->assertArrayValues( array(), Emitter::get_surrogate_keys() );
89+
}
90+
91+
public function test_month_date_archive_with_posts() {
92+
$this->go_to( home_url( '?year=2016&monthnum=10' ) );
93+
$this->assertArrayValues( array(
94+
'archive',
95+
'date',
96+
'post-' . $this->post_id1,
97+
'post-' . $this->post_id2,
98+
'post-' . $this->post_id3,
99+
'user-' . $this->user_id1,
100+
'user-' . $this->user_id2,
101+
), Emitter::get_surrogate_keys() );
102+
}
103+
104+
public function test_month_date_archive_without_posts() {
105+
$this->go_to( home_url( '?year=2015&monthnum=10' ) );
106+
$this->assertArrayValues( array(), Emitter::get_surrogate_keys() );
107+
}
108+
109+
public function test_day_date_archive_with_posts() {
110+
$this->go_to( home_url( '?year=2016&monthnum=10&day=15' ) );
111+
$this->assertArrayValues( array(
112+
'archive',
113+
'date',
114+
'post-' . $this->post_id3,
115+
'user-' . $this->user_id2,
116+
), Emitter::get_surrogate_keys() );
117+
}
118+
119+
public function test_day_date_archive_without_posts() {
120+
$this->go_to( home_url( '?year=2015&monthnum=10&day=15' ) );
121+
$this->assertArrayValues( array(), Emitter::get_surrogate_keys() );
122+
}
123+
72124
public function test_search() {
73125
$this->go_to( home_url( '/?s=foo' ) );
74126
$this->assertArrayValues( array(

0 commit comments

Comments
 (0)