Files
InvoiceShelf/tests/Feature/Admin/Modules/ModuleResourceTest.php
T
Darko Gjorgjijoski 5ef7804e60 refactor: adopt modular domain architecture (#747)
* 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
2026-08-05 17:40:03 +02:00

102 lines
3.6 KiB
PHP

<?php
use App\Platform\Modules\Http\Resources\ModuleResource;
use App\Platform\Modules\Models\Module as InstalledModule;
use Illuminate\Http\Request;
it('maps the marketplace payload shape expected by the admin modules ui', function () {
$payload = [
'id' => 7,
'slug' => 'sales-tax-us',
'name' => 'Sales Tax US',
'module_name' => 'SalesTaxUs',
'access_tier' => 'premium',
'cover' => 'https://example.com/cover.png',
'short_description' => 'Short description',
'long_description' => 'Long description',
'highlights' => ['Fast install'],
'screenshots' => [['url' => 'https://example.com/shot.png', 'title' => 'Shot']],
'faq' => [['question' => 'Q', 'answer' => 'A']],
'links' => [['icon' => 'BookOpenIcon', 'label' => 'Docs', 'link' => 'https://example.com/docs']],
'video_link' => null,
'video_thumbnail' => null,
'type' => 'integration',
'is_dev' => false,
'author_name' => 'InvoiceShelf',
'author_avatar' => 'https://example.com/avatar.png',
'latest_module_version' => '1.2.0',
'latest_module_version_updated_at' => now()->toIso8601String(),
'latest_min_invoiceshelf_version' => '3.0.0',
'latest_module_checksum_sha256' => hash('sha256', 'sales-tax-us-1.2.0'),
'installed_module_version' => null,
'installed_module_version_updated_at' => null,
'installed' => false,
'enabled' => false,
'update_available' => false,
'reviews' => [],
'average_rating' => null,
'monthly_price' => null,
'yearly_price' => null,
'purchased' => true,
'license' => null,
];
$data = (new ModuleResource($payload))->toArray(Request::create('/'));
expect($data)->toMatchArray([
'slug' => 'sales-tax-us',
'module_name' => 'SalesTaxUs',
'access_tier' => 'premium',
'author_name' => 'InvoiceShelf',
'latest_module_version' => '1.2.0',
'latest_min_invoiceshelf_version' => '3.0.0',
]);
});
it('overlays installed module state and update availability locally', function () {
InstalledModule::query()->create([
'name' => 'SalesTaxUs',
'version' => '1.0.0',
'installed' => true,
'enabled' => true,
]);
$payload = (object) [
'id' => 7,
'slug' => 'sales-tax-us',
'name' => 'Sales Tax US',
'module_name' => 'SalesTaxUs',
'access_tier' => 'public',
'cover' => null,
'short_description' => null,
'long_description' => null,
'highlights' => null,
'screenshots' => null,
'faq' => null,
'links' => null,
'video_link' => null,
'video_thumbnail' => null,
'type' => null,
'is_dev' => false,
'author_name' => 'InvoiceShelf',
'author_avatar' => null,
'latest_module_version' => '1.1.0',
'latest_module_version_updated_at' => now()->toIso8601String(),
'latest_min_invoiceshelf_version' => '3.0.0',
'latest_module_checksum_sha256' => hash('sha256', 'sales-tax-us-1.1.0'),
'reviews' => [],
'average_rating' => null,
'monthly_price' => null,
'yearly_price' => null,
'purchased' => true,
'license' => null,
];
$data = (new ModuleResource($payload))->toArray(Request::create('/'));
expect($data['installed'])->toBeTrue()
->and($data['enabled'])->toBeTrue()
->and($data['installed_module_version'])->toBe('1.0.0')
->and($data['update_available'])->toBeTrue();
});