mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-02 21:31:01 +00:00
* refactor: stabilize model identities for domain migration * refactor: extract module platform context * refactor: assign models to domain contexts * refactor: extract ai platform context * refactor: extract storage platform context * refactor: extract mail platform context * refactor: extract pdf platform context * refactor: extract operations platform context * refactor: move installation into operations platform * refactor: extract money domain context * refactor: extract taxation domain context * refactor: extract catalog domain context * refactor: extract metadata domain context * refactor: extract reporting domain context * refactor: extract purchases domain context * refactor: extract receivables domain context * refactor: extract accounts domain context * refactor: complete reporting statement boundary * refactor: extract contacts domain context * refactor: extract sales domain context * refactor: remove legacy application layers * fix: migrate legacy bouncer role identities
63 lines
3.5 KiB
PHP
63 lines
3.5 KiB
PHP
<?php
|
|
|
|
use App\Adapters\Money\EloquentExchangeRateBackfill;
|
|
use App\Domains\Money\Contracts\ExchangeRateBackfill;
|
|
use App\Domains\Money\ExchangeRates\CurrencyConverterDriver;
|
|
use App\Domains\Money\ExchangeRates\CurrencyFreakDriver;
|
|
use App\Domains\Money\Models\ExchangeRateProvider;
|
|
use App\Domains\Money\MoneyServiceProvider;
|
|
use App\Domains\Money\Policies\ExchangeRateProviderPolicy;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\Route;
|
|
use InvoiceShelf\Modules\Registry;
|
|
|
|
test('the money domain owns exchange-rate behavior and authorization', function () {
|
|
expect(app()->getProviders(MoneyServiceProvider::class))->toHaveCount(1)
|
|
->and(app(ExchangeRateBackfill::class))->toBeInstanceOf(EloquentExchangeRateBackfill::class)
|
|
->and(Gate::getPolicyFor(ExchangeRateProvider::class))->toBeInstanceOf(ExchangeRateProviderPolicy::class)
|
|
->and(Registry::driverMeta('exchange_rate', 'currency_converter')['class'] ?? null)
|
|
->toBe(CurrencyConverterDriver::class)
|
|
->and(Registry::driverMeta('exchange_rate', 'currency_freak')['class'] ?? null)
|
|
->toBe(CurrencyFreakDriver::class);
|
|
|
|
expect(class_exists('App\\Providers\\DriverRegistryProvider'))->toBeFalse()
|
|
->and(class_exists('App\\Support\\ExchangeRate\\ExchangeRateDriverFactory'))->toBeFalse()
|
|
->and(class_exists('App\\Services\\Document\\CurrencyService'))->toBeFalse()
|
|
->and(class_exists('App\\Services\\ExchangeRateProviderService'))->toBeFalse()
|
|
->and(class_exists('App\\Policies\\ExchangeRateProviderPolicy'))->toBeFalse()
|
|
->and(class_exists('App\\Http\\Controllers\\Admin\\CurrenciesController'))->toBeFalse()
|
|
->and(class_exists('App\\Http\\Controllers\\Company\\ExchangeRate\\ExchangeRateProviderController'))->toBeFalse()
|
|
->and(class_exists('App\\Http\\Requests\\ExchangeRateProviderRequest'))->toBeFalse()
|
|
->and(class_exists('App\\Http\\Resources\\CurrencyResource'))->toBeFalse()
|
|
->and(class_exists('App\\Http\\Resources\\Customer\\CurrencyResource'))->toBeFalse();
|
|
});
|
|
|
|
test('the money domain preserves its public routes and middleware', function () {
|
|
$routes = collect(Route::getRoutes()->getRoutes())
|
|
->filter(fn ($route): bool => preg_match(
|
|
'#^api/v1/(?:currencies(?:$|/)|exchange-rate-providers(?:$|/)|supported-currencies$|used-currencies$)#',
|
|
$route->uri(),
|
|
) === 1)
|
|
->keyBy(fn ($route): string => implode('|', $route->methods()).' '.$route->uri());
|
|
|
|
expect($routes->keys()->sort()->values()->all())->toBe(collect([
|
|
'DELETE api/v1/exchange-rate-providers/{exchange_rate_provider}',
|
|
'GET|HEAD api/v1/currencies',
|
|
'GET|HEAD api/v1/currencies/used',
|
|
'GET|HEAD api/v1/currencies/{currency}/active-provider',
|
|
'GET|HEAD api/v1/currencies/{currency}/exchange-rate',
|
|
'GET|HEAD api/v1/exchange-rate-providers',
|
|
'GET|HEAD api/v1/exchange-rate-providers/{exchange_rate_provider}',
|
|
'GET|HEAD api/v1/supported-currencies',
|
|
'GET|HEAD api/v1/used-currencies',
|
|
'POST api/v1/currencies/bulk-update-exchange-rate',
|
|
'POST api/v1/exchange-rate-providers',
|
|
'PUT|PATCH api/v1/exchange-rate-providers/{exchange_rate_provider}',
|
|
])->sort()->values()->all());
|
|
|
|
foreach ($routes as $route) {
|
|
expect($route->getActionName())->toStartWith('App\\Domains\\Money\\Http\\Controllers\\')
|
|
->and($route->gatherMiddleware())->toContain('auth:sanctum', 'company', 'bouncer');
|
|
}
|
|
});
|