1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 07:33:04 +01:00
invoiceninja/tests/Unit/RecurringDateTest.php

60 lines
1.3 KiB
PHP
Raw Normal View History

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)
*
* @license https://www.elastic.co/licensing/elastic-license
2021-03-29 04:14:55 +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;
/**
* @test
*/
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()
{
$trial = 60 * 60 * 24;
2021-03-29 04:14:55 +02:00
$now = Carbon::parse('2021-12-01');
2021-03-29 04:14:55 +02:00
$trial_ends = $now->addSeconds($trial)->addDays(1);
2021-03-29 04:14:55 +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'));
// $next_month = $today->addMonthNoOverflow();
// $this->assertEquals('2022-03-31', $next_month->format('Y-m-d'));
}
}