Skip to content

Commit 86bb4fc

Browse files
committed
Tests: Cover calendar weekday normalization.
Test `calendar_week_mod()` at positive and negative week boundaries. Verify that offsets wrap into the expected weekday range and preserve the float return type. Developed in: #14632 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64751 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 856699c commit 86bb4fc

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/**
4+
* Tests for calendar_week_mod().
5+
*
6+
* @group general
7+
*
8+
* @covers ::calendar_week_mod
9+
*/
10+
class Tests_General_CalendarWeekMod extends WP_UnitTestCase {
11+
12+
/**
13+
* @ticket 65819
14+
*
15+
* @dataProvider data_calendar_week_mod
16+
*
17+
* @param int $num Number of day.
18+
* @param float $expected Days since the start of the week.
19+
*/
20+
public function test_calendar_week_mod( $num, $expected ) {
21+
$this->assertSame( $expected, calendar_week_mod( $num ) );
22+
}
23+
24+
/**
25+
* Data provider.
26+
*
27+
* @return array[]
28+
*/
29+
public static function data_calendar_week_mod() {
30+
return array(
31+
'start of week' => array( 0, 0.0 ),
32+
'first weekday' => array( 1, 1.0 ),
33+
'last weekday before wrap' => array( 6, 6.0 ),
34+
'exact week boundary' => array( 7, 0.0 ),
35+
'day after wrap' => array( 8, 1.0 ),
36+
'two weeks' => array( 14, 0.0 ),
37+
'large offset' => array( 20, 6.0 ),
38+
'negative offset' => array( -1, 6.0 ),
39+
'negative six days' => array( -6, 1.0 ),
40+
'negative week boundary' => array( -7, 0.0 ),
41+
'negative beyond boundary' => array( -8, 6.0 ),
42+
);
43+
}
44+
}

0 commit comments

Comments
 (0)