datesUtils = new DatesUtils(); $this->trial = new Trial($this->datesUtils); } public function tearDown(): void { DatesUtils::clearFakeDatetime(); } /** * @see Trial::getTrialCountdown() */ public function testGetTrialCountdownWithNullStartDate(): void { $result = $this->trial->getTrialCountdown(null); $this->assertEquals(0, $result); } /** * @see Trial::getTrialCountdown() */ public function testGetTrialCountdownWithRecentStartDate(): void { // Set up a trial start date $trialStartDate = new \DateTime('2023-01-01'); // Set the current date to be 10 days after the trial start date DatesUtils::setFakeDatetime('2023-01-11'); $result = $this->trial->getTrialCountdown($trialStartDate); // Should return 30 - 10 = 20 days remaining $this->assertEquals(20, $result); } /** * @see Trial::getTrialCountdown() */ public function testGetTrialCountdownWithExactly30DaysAgo(): void { // Set up a trial start date $trialStartDate = new \DateTime('2023-01-01'); // Set the current date to be 30 days after the trial start date DatesUtils::setFakeDatetime('2023-01-31'); $result = $this->trial->getTrialCountdown($trialStartDate); // Should return 30 - 30 = 0 days remaining $this->assertEquals(0, $result); } /** * @see Trial::getTrialCountdown() */ public function testGetTrialCountdownWithOldStartDate(): void { // Set up a trial start date $trialStartDate = new \DateTime('2023-01-01'); // Set the current date to be 40 days after the trial start date DatesUtils::setFakeDatetime('2023-02-10'); $result = $this->trial->getTrialCountdown($trialStartDate); // Should return 0 days remaining since the trial has expired $this->assertEquals(0, $result); } }