value)->toBe('3D mallinnus') ->and(fn () => new CatalogName(' '))->toThrow(InvalidCatalogName::class) ->and(fn () => new CatalogName(str_repeat('a', 101)))->toThrow(InvalidCatalogName::class); }); it('gives the shared unit no services', function () { $shared = ServiceUnit::reconstitute(1, new CatalogName('Kaikille yhteiset'), true, true, 1); Service::create($shared, new CatalogName('Palvelu'), 1); })->throws(SharedUnitHasNoServices::class); it('puts a work type only under a service of its own unit', function () { $media = ServiceUnit::reconstitute(1, new CatalogName('Mediatuotanto'), false, true, 1); $marketing = ServiceUnit::reconstitute(2, new CatalogName('Markkinointi'), false, true, 2); $video = Service::reconstitute(10, 1, new CatalogName('Videotuotanto'), true, 1); expect(WorkType::create($media, $video, new CatalogName('editointi'), 1)->serviceId())->toBe(10) ->and(fn () => WorkType::create($marketing, $video, new CatalogName('editointi'), 1))->toThrow(ServiceNotInUnit::class); }); it('deactivates, activates and swaps order', function () { $first = ServiceUnit::reconstitute(1, new CatalogName('A'), false, true, 1); $second = ServiceUnit::reconstitute(2, new CatalogName('B'), false, true, 2); $first->deactivate(); $first->swapOrderWith($second); expect($first->isActive())->toBeFalse() ->and($first->sortOrder())->toBe(2) ->and($second->sortOrder())->toBe(1); $first->activate(); expect($first->isActive())->toBeTrue(); });