mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-04 21:23:36 +00:00
Cover preferred format methods of the Navigation class
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* NavigationPreferredCarbonFormatByPeriodTest.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support;
|
||||
|
||||
use FireflyIII\Support\Navigation;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @group unit-test
|
||||
* @group support
|
||||
* @group navigation
|
||||
*/
|
||||
class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
parent::__construct($name);
|
||||
$this->navigation = new Navigation();
|
||||
}
|
||||
|
||||
public static function providePeriods(): array
|
||||
{
|
||||
return [
|
||||
'unknown' => ['period' => '1day', 'expected' => 'Y-m-d'],
|
||||
'week' => ['period' => '1W', 'expected' => '\WW,Y'],
|
||||
'month' => ['period' => '1M', 'expected' => 'Y-m'],
|
||||
'quarterly' => ['period' => '3M', 'expected' => '\QQ,Y'],
|
||||
'half-yearly' => ['period' => '6M', 'expected' => '\QQ,Y'],
|
||||
'yearly' => ['period' => '1Y', 'expected' => 'Y'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providePeriods
|
||||
*/
|
||||
public function testGivenAPeriodWhenCallPreferredCarbonFormatByPeriodThenReturnsExpectedFormat(string $period, string $expected)
|
||||
{
|
||||
$formatPeriod = $this->navigation->preferredCarbonFormatByPeriod($period);
|
||||
$this->assertEquals($expected, $formatPeriod);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user