From ff9672e1551c75b98d00e5d2ca5f635a1ab5a4f1 Mon Sep 17 00:00:00 2001 From: Gregor Vostrak Date: Fri, 9 May 2025 17:45:02 +0200 Subject: [PATCH] fix shared report endpoint test to check new structure that includes organization format properties, format --- app/Http/Controllers/Api/V1/CurrencyController.php | 3 ++- .../Resources/V1/Organization/OrganizationResource.php | 4 ++-- .../Endpoint/Api/V1/Public/PublicReportEndpointTest.php | 9 +++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/V1/CurrencyController.php b/app/Http/Controllers/Api/V1/CurrencyController.php index 56c595c2..96157c98 100644 --- a/app/Http/Controllers/Api/V1/CurrencyController.php +++ b/app/Http/Controllers/Api/V1/CurrencyController.php @@ -15,6 +15,7 @@ class CurrencyController extends Controller * Get all currencies * * @response array{code: string, name: string, symbol: string}[] + * * @operationId getCurrencies */ public function index(): JsonResponse @@ -26,7 +27,7 @@ class CurrencyController extends Controller 'code' => $currency->getCurrencyCode(), 'name' => $currency->getName(), 'symbol' => $currencyService->getCurrencySymbol($currency->getCurrencyCode()), - ], + ], ISOCurrencyProvider::getInstance()->getAvailableCurrencies() )); diff --git a/app/Http/Resources/V1/Organization/OrganizationResource.php b/app/Http/Resources/V1/Organization/OrganizationResource.php index 5672c999..f6ceee74 100644 --- a/app/Http/Resources/V1/Organization/OrganizationResource.php +++ b/app/Http/Resources/V1/Organization/OrganizationResource.php @@ -40,9 +40,9 @@ class OrganizationResource extends BaseResource */ public function toArray(Request $request): array { - $currencyService = app(CurrencyService::class); + $currencyService = app(CurrencyService::class); - return [ + return [ /** @var string $id ID */ 'id' => $this->resource->id, /** @var string $name Name */ diff --git a/tests/Unit/Endpoint/Api/V1/Public/PublicReportEndpointTest.php b/tests/Unit/Endpoint/Api/V1/Public/PublicReportEndpointTest.php index b0b81e9d..7345792e 100644 --- a/tests/Unit/Endpoint/Api/V1/Public/PublicReportEndpointTest.php +++ b/tests/Unit/Endpoint/Api/V1/Public/PublicReportEndpointTest.php @@ -14,6 +14,7 @@ use App\Models\Report; use App\Models\Tag; use App\Models\Task; use App\Models\TimeEntry; +use App\Service\CurrencyService; use App\Service\Dto\ReportPropertiesDto; use Illuminate\Support\Str; use Tests\Unit\Endpoint\Api\V1\ApiEndpointTestAbstract; @@ -104,6 +105,8 @@ class PublicReportEndpointTest extends ApiEndpointTestAbstract TimeEntry::factory()->forOrganization($organization)->forTask($task2)->startWithDuration(now()->subDay(), 100)->create(); TimeEntry::factory()->forOrganization($organization)->startWithDuration(now()->subDay(), 100)->create(); + $currencyService = app(CurrencyService::class); + // Act $response = $this->getJson(route('api.v1.public.reports.show'), [ 'X-Api-Key' => $report->share_secret, @@ -116,6 +119,12 @@ class PublicReportEndpointTest extends ApiEndpointTestAbstract 'description' => $report->description, 'public_until' => $report->public_until?->toIso8601ZuluString(), 'currency' => $organization->currency, + 'number_format' => $organization->number_format, + 'interval_format' => $organization->interval_format, + 'currency_format' => $organization->currency_format, + 'currency_symbol' => $currencyService->getCurrencySymbol($organization->currency), + 'time_format' => $organization->time_format, + 'date_format' => $organization->date_format, 'properties' => [ 'group' => $reportDto->group->value, 'sub_group' => $reportDto->subGroup->value,