2021-03-29 04:14:55 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
2022-06-21 11:57:17 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2021-03-29 04:14:55 +02:00
|
|
|
*/
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2021-03-29 04:14:55 +02:00
|
|
|
namespace Tests\Unit;
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
use Tests\MockAccountData;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
2024-09-16 13:13:55 +02:00
|
|
|
*
|
2021-03-29 04:14:55 +02:00
|
|
|
*/
|
|
|
|
class RecurringDateTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
use MockAccountData;
|
|
|
|
|
2024-08-22 08:57:52 +02:00
|
|
|
protected function setUp(): void
|
2021-03-29 04:14:55 +02:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
//$this->makeTestData();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNextDay()
|
|
|
|
{
|
2022-06-21 11:57:17 +02:00
|
|
|
$trial = 60 * 60 * 24;
|
2021-03-29 04:14:55 +02:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
$now = Carbon::parse('2021-12-01');
|
2021-03-29 04:14:55 +02:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
$trial_ends = $now->addSeconds($trial)->addDays(1);
|
2021-03-29 04:14:55 +02:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
$this->assertequals($trial_ends->format('Y-m-d'), '2021-12-03');
|
2021-03-29 04:14:55 +02:00
|
|
|
}
|
2023-08-31 03:51:25 +02:00
|
|
|
|
|
|
|
public function testDateOverflowsForEndOfMonth()
|
|
|
|
{
|
|
|
|
$today = Carbon::parse('2022-01-31');
|
|
|
|
|
|
|
|
$next_month = $today->addMonthNoOverflow();
|
|
|
|
|
|
|
|
$this->assertEquals('2022-02-28', $next_month->format('Y-m-d'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|