This should fix the tests again.

This commit is contained in:
James Cole 2024-02-03 10:08:34 +01:00
parent 9894d16d26
commit d3f19db42d
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
6 changed files with 54 additions and 49 deletions

View File

@ -226,16 +226,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.48.0",
"version": "v3.49.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "a92472c6fb66349de25211f31c77eceae3df024e"
"reference": "8742f7aa6f72a399688b65e4f58992c2d4681fc2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/a92472c6fb66349de25211f31c77eceae3df024e",
"reference": "a92472c6fb66349de25211f31c77eceae3df024e",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8742f7aa6f72a399688b65e4f58992c2d4681fc2",
"reference": "8742f7aa6f72a399688b65e4f58992c2d4681fc2",
"shasum": ""
},
"require": {
@ -305,7 +305,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.48.0"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.49.0"
},
"funding": [
{
@ -313,7 +313,7 @@
"type": "github"
}
],
"time": "2024-01-19T21:44:39+00:00"
"time": "2024-02-02T00:41:40+00:00"
},
{
"name": "psr/container",

View File

@ -395,16 +395,16 @@
},
{
"name": "symfony/config",
"version": "v7.0.0",
"version": "v7.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
"reference": "8789646600f4e7e451dde9e1dc81cfa429f3857a"
"reference": "86a5027869ca3d6bdecae6d5d6c2f77c8f2c1d16"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/config/zipball/8789646600f4e7e451dde9e1dc81cfa429f3857a",
"reference": "8789646600f4e7e451dde9e1dc81cfa429f3857a",
"url": "https://api.github.com/repos/symfony/config/zipball/86a5027869ca3d6bdecae6d5d6c2f77c8f2c1d16",
"reference": "86a5027869ca3d6bdecae6d5d6c2f77c8f2c1d16",
"shasum": ""
},
"require": {
@ -450,7 +450,7 @@
"description": "Helps you find, load, combine, autofill and validate configuration values of any kind",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/config/tree/v7.0.0"
"source": "https://github.com/symfony/config/tree/v7.0.3"
},
"funding": [
{
@ -466,20 +466,20 @@
"type": "tidelift"
}
],
"time": "2023-11-09T08:30:23+00:00"
"time": "2024-01-30T08:34:29+00:00"
},
{
"name": "symfony/dependency-injection",
"version": "v7.0.2",
"version": "v7.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
"reference": "bd25ef7c937b9da12510bdc4f1c66728f19620e3"
"reference": "e915c6684b8e3ae90a4441f6823ebbb40edf0b92"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/bd25ef7c937b9da12510bdc4f1c66728f19620e3",
"reference": "bd25ef7c937b9da12510bdc4f1c66728f19620e3",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/e915c6684b8e3ae90a4441f6823ebbb40edf0b92",
"reference": "e915c6684b8e3ae90a4441f6823ebbb40edf0b92",
"shasum": ""
},
"require": {
@ -530,7 +530,7 @@
"description": "Allows you to standardize and centralize the way objects are constructed in your application",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/dependency-injection/tree/v7.0.2"
"source": "https://github.com/symfony/dependency-injection/tree/v7.0.3"
},
"funding": [
{
@ -546,7 +546,7 @@
"type": "tidelift"
}
],
"time": "2023-12-28T19:18:20+00:00"
"time": "2024-01-30T08:34:29+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -617,16 +617,16 @@
},
{
"name": "symfony/filesystem",
"version": "v7.0.0",
"version": "v7.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "7da8ea2362a283771478c5f7729cfcb43a76b8b7"
"reference": "2890e3a825bc0c0558526c04499c13f83e1b6b12"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/7da8ea2362a283771478c5f7729cfcb43a76b8b7",
"reference": "7da8ea2362a283771478c5f7729cfcb43a76b8b7",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/2890e3a825bc0c0558526c04499c13f83e1b6b12",
"reference": "2890e3a825bc0c0558526c04499c13f83e1b6b12",
"shasum": ""
},
"require": {
@ -660,7 +660,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v7.0.0"
"source": "https://github.com/symfony/filesystem/tree/v7.0.3"
},
"funding": [
{
@ -676,7 +676,7 @@
"type": "tidelift"
}
],
"time": "2023-07-27T06:33:22+00:00"
"time": "2024-01-23T15:02:46+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -927,16 +927,16 @@
},
{
"name": "symfony/var-exporter",
"version": "v7.0.2",
"version": "v7.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-exporter.git",
"reference": "345c62fefe92243c3a06fc0cc65f2ec1a47e0764"
"reference": "1fb79308cb5fc2b44bff6e8af10a5af6812e05b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/345c62fefe92243c3a06fc0cc65f2ec1a47e0764",
"reference": "345c62fefe92243c3a06fc0cc65f2ec1a47e0764",
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/1fb79308cb5fc2b44bff6e8af10a5af6812e05b8",
"reference": "1fb79308cb5fc2b44bff6e8af10a5af6812e05b8",
"shasum": ""
},
"require": {
@ -981,7 +981,7 @@
"serialize"
],
"support": {
"source": "https://github.com/symfony/var-exporter/tree/v7.0.2"
"source": "https://github.com/symfony/var-exporter/tree/v7.0.3"
},
"funding": [
{
@ -997,7 +997,7 @@
"type": "tidelift"
}
],
"time": "2023-12-27T08:42:13+00:00"
"time": "2024-01-23T15:02:46+00:00"
}
],
"aliases": [],

View File

@ -74,6 +74,7 @@ class TriggerRequest extends FormRequest
if(null === $this->get('accounts')) {
return [];
}
return $this->get('accounts');
}
}

View File

@ -216,6 +216,7 @@ class Navigation
public function endOfPeriod(Carbon $end, string $repeatFreq): Carbon
{
$currentEnd = clone $end;
Log::debug(sprintf('endOfPeriod("%s", "%s")', $currentEnd->format('Y-m-d'), $repeatFreq));
$functionMap = [
'1D' => 'endOfDay',
@ -236,27 +237,25 @@ class Navigation
'yearly' => 'addYear',
'1Y' => 'addYear',
];
$modifierMap = [
'quarter' => 3,
'3M' => 3,
'quarterly' => 3,
'half-year' => 6,
'half_year' => 6,
'6M' => 6,
];
$modifierMap = ['quarter' => 3, '3M' => 3, 'quarterly' => 3, 'half-year' => 6, 'half_year' => 6, '6M' => 6];
$subDay = ['week', 'weekly', '1W', 'month', 'monthly', '1M', '3M', 'quarter', 'quarterly', '6M', 'half-year', 'half_year', '1Y', 'year', 'yearly'];
// if the range is custom, the end of the period
// is another X days (x is the difference between start)
// and end added to $theCurrentEnd
if ('custom' === $repeatFreq) {
/** @var Carbon $tStart */
$tStart = session('start', today(config('app.timezone'))->startOfMonth());
// if the repeat frequency is "custom", use the current session start/end to see how large the range is,
// and use that to "add" another period.
// if there is no session data available use "30 days" as a default.
$diffInDays = 30;
if (null !== session('start') && null !== session('end')) {
Log::debug('Session data available.');
/** @var Carbon $tEnd */
$tEnd = session('end', today(config('app.timezone'))->endOfMonth());
$diffInDays = $tStart->diffInDays($tEnd);
/** @var Carbon $tStart */
$tStart = session('start', today(config('app.timezone'))->startOfMonth());
/** @var Carbon $tEnd */
$tEnd = session('end', today(config('app.timezone'))->endOfMonth());
$diffInDays = $tStart->diffInDays($tEnd);
}
Log::debug(sprintf('Diff in days is %d', $diffInDays));
$currentEnd->addDays($diffInDays);
return $currentEnd;

View File

@ -35,6 +35,11 @@ use Tests\integration\TestCase;
*/
final class NavigationCustomEndOfPeriodTest extends TestCase
{
public function __construct(string $name)
{
parent::__construct($name);
}
/**
* @preserveGlobalState disabled
*/

View File

@ -26,7 +26,7 @@ namespace Tests\unit\Support;
use Carbon\Carbon;
use FireflyIII\Support\Navigation;
use Illuminate\Support\Facades\Log;
use PHPUnit\Framework\TestCase;
use Tests\integration\TestCase;
/**
* @group unit-test
@ -78,7 +78,7 @@ final class NavigationEndOfPeriodTest extends TestCase
}
/**
* @dataProvider provideDates
* @dataProvider provideDates
*/
public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
{