@@ -35,6 +35,38 @@ public function provideMonths(): iterable
3535 yield ['2020-06-30 ' , '2020-07-31 ' ];
3636 }
3737
38+ /** @dataProvider provideRemoveMonths */
39+ public function testRemoveMonth (string $ from , string $ expected ): void
40+ {
41+ self ::assertSame ($ expected , $ this ->timeTraveler ->removeMonth (new AbsoluteDate ($ from ))->__toString ());
42+ }
43+
44+ /** @return iterable<string, array{string, string}> */
45+ public function provideRemoveMonths (): iterable
46+ {
47+ foreach (
48+ [
49+ '2020-01-01 ' => '2019-12-01 ' ,
50+ '2020-01-28 ' => '2019-12-28 ' ,
51+ '2020-01-29 ' => '2019-12-29 ' ,
52+ '2020-01-30 ' => '2019-12-30 ' ,
53+ '2020-01-31 ' => '2019-12-31 ' ,
54+ '2020-02-29 ' => '2020-01-31 ' ,
55+ '2020-06-30 ' => '2020-05-31 ' ,
56+ '2023-10-31 ' => '2023-09-30 ' ,
57+ '2023-08-31 ' => '2023-07-31 ' ,
58+ '2023-09-30 ' => '2023-08-31 ' ,
59+ '2023-03-31 ' => '2023-02-28 ' ,
60+ '2024-03-31 ' => '2024-02-29 ' ,
61+ ] as $ currentMonth => $ expectedPreviousMonth
62+ ) {
63+ yield sprintf ('%s: previous month will %s ' , $ currentMonth , $ expectedPreviousMonth ) => [
64+ $ currentMonth ,
65+ $ expectedPreviousMonth ,
66+ ];
67+ }
68+ }
69+
3870 /** @dataProvider provideMonthsWithReference */
3971 public function testAddMonthWithReference (string $ reference , string $ from , string $ expected ): void
4072 {
0 commit comments