From 2c7f87918887e2a7c93cc6156e8705ce493d8b16 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Thu, 26 May 2016 15:47:52 +0000 Subject: [PATCH] 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 --- .../tests/functions/getWeekstartend.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/phpunit/tests/functions/getWeekstartend.php diff --git a/tests/phpunit/tests/functions/getWeekstartend.php b/tests/phpunit/tests/functions/getWeekstartend.php new file mode 100644 index 0000000000..978f49eee7 --- /dev/null +++ b/tests/phpunit/tests/functions/getWeekstartend.php @@ -0,0 +1,47 @@ + 1454889600, + 'end' => 1455494399, + ); + + $this->assertEquals( $expected, get_weekstartend( '2016-02-12' ) ); + } + + public function test_start_of_week_sunday() { + $expected = array( + 'start' => 1454803200, + 'end' => 1455407999, + ); + + $this->assertEquals( $expected, get_weekstartend( '2016-02-12', 0 ) ); + } + + public function test_start_of_week_should_fall_back_on_start_of_week_option() { + update_option( 'start_of_week', 2 ); + + $expected = array( + 'start' => 1454976000, + 'end' => 1455580799, + ); + + $this->assertEquals( $expected, get_weekstartend( '2016-02-12' ) ); + } + + public function test_start_of_week_should_fall_back_on_sunday_when_option_is_missing() { + delete_option( 'start_of_week' ); + + $expected = array( + 'start' => 1454803200, + 'end' => 1455407999, + ); + + $this->assertEquals( $expected, get_weekstartend( '2016-02-12' ) ); + } +}