Skip to content

Commit 89cd851

Browse files
author
boonebgorges
committed
Add tests for get_weekstartend().
Props pbearne, tloureiro. Fixes #36415. git-svn-id: https://develop.svn.wordpress.org/trunk@37579 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 93ec92c commit 89cd851

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
/**
4+
* @group functions.php
5+
*/
6+
class Tests_Functions_GetWeekstartend extends WP_UnitTestCase {
7+
8+
public function test_default_start_of_week_option_is_monday() {
9+
$expected = array(
10+
'start' => 1454889600,
11+
'end' => 1455494399,
12+
);
13+
14+
$this->assertEquals( $expected, get_weekstartend( '2016-02-12' ) );
15+
}
16+
17+
public function test_start_of_week_sunday() {
18+
$expected = array(
19+
'start' => 1454803200,
20+
'end' => 1455407999,
21+
);
22+
23+
$this->assertEquals( $expected, get_weekstartend( '2016-02-12', 0 ) );
24+
}
25+
26+
public function test_start_of_week_should_fall_back_on_start_of_week_option() {
27+
update_option( 'start_of_week', 2 );
28+
29+
$expected = array(
30+
'start' => 1454976000,
31+
'end' => 1455580799,
32+
);
33+
34+
$this->assertEquals( $expected, get_weekstartend( '2016-02-12' ) );
35+
}
36+
37+
public function test_start_of_week_should_fall_back_on_sunday_when_option_is_missing() {
38+
delete_option( 'start_of_week' );
39+
40+
$expected = array(
41+
'start' => 1454803200,
42+
'end' => 1455407999,
43+
);
44+
45+
$this->assertEquals( $expected, get_weekstartend( '2016-02-12' ) );
46+
}
47+
}

0 commit comments

Comments
 (0)