Halte Auswirkung und Rückzug beim Veröffentlichen eines Artikel-Stands fest.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
fd6860efda
commit
fef0ea2ac2
11 files changed
+298
-25
No files matched your search
@@ -18,6 +18,7 @@ class ArticleRelease extends Model
|
|||||||
'block_reason',
|
'block_reason',
|
||||||
'fallback_release_id',
|
'fallback_release_id',
|
||||||
'change_note',
|
'change_note',
|
||||||
|
'impact_report',
|
||||||
'root_element_version_id',
|
'root_element_version_id',
|
||||||
'root_composition_version_id',
|
'root_composition_version_id',
|
||||||
];
|
];
|
||||||
@@ -27,6 +28,7 @@ protected function casts(): array
|
|||||||
return [
|
return [
|
||||||
'important' => 'boolean',
|
'important' => 'boolean',
|
||||||
'status' => ReleaseStatus::class,
|
'status' => ReleaseStatus::class,
|
||||||
|
'impact_report' => 'array',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,24 +36,40 @@ protected static function booted(): void
|
|||||||
{
|
{
|
||||||
static::updating(function (ArticleRelease $release): void {
|
static::updating(function (ArticleRelease $release): void {
|
||||||
$original = StatusValue::of($release->getOriginal('status'));
|
$original = StatusValue::of($release->getOriginal('status'));
|
||||||
|
$next = StatusValue::of($release->status);
|
||||||
if (! in_array($original, [
|
$locked = [
|
||||||
ReleaseStatus::Veroeffentlicht->value,
|
ReleaseStatus::Veroeffentlicht->value,
|
||||||
ReleaseStatus::AbgeloestVerfuegbar->value,
|
ReleaseStatus::AbgeloestVerfuegbar->value,
|
||||||
], true)) {
|
ReleaseStatus::Gesperrt->value,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (! in_array($original, $locked, true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dirty = array_diff(array_keys($release->getDirty()), ['status', 'updated_at']);
|
$allowedFields = ['status', 'updated_at'];
|
||||||
|
|
||||||
if ($dirty !== []) {
|
if ($original === ReleaseStatus::Veroeffentlicht->value && $next === ReleaseStatus::Gesperrt->value) {
|
||||||
|
$allowedFields = ['status', 'updated_at', 'block_reason', 'fallback_release_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_diff(array_keys($release->getDirty()), $allowedFields) !== []) {
|
||||||
throw new DomainRuleException('Ein veröffentlichter Artikel-Stand ist unveränderlich.');
|
throw new DomainRuleException('Ein veröffentlichter Artikel-Stand ist unveränderlich.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$next = StatusValue::of($release->status);
|
$allowed = match ($original) {
|
||||||
|
ReleaseStatus::Veroeffentlicht->value => [
|
||||||
|
ReleaseStatus::AbgeloestVerfuegbar->value,
|
||||||
|
ReleaseStatus::Gesperrt->value,
|
||||||
|
],
|
||||||
|
ReleaseStatus::AbgeloestVerfuegbar->value => [
|
||||||
|
ReleaseStatus::Veroeffentlicht->value,
|
||||||
|
],
|
||||||
|
default => [],
|
||||||
|
};
|
||||||
|
|
||||||
if ($original === ReleaseStatus::Veroeffentlicht->value && $next !== ReleaseStatus::AbgeloestVerfuegbar->value) {
|
if (! in_array($next, $allowed, true)) {
|
||||||
throw new DomainRuleException('Ein veröffentlichter Artikel-Stand kann nur abgelöst werden.');
|
throw new DomainRuleException('Dieser Statuswechsel eines Artikel-Stands ist nicht zulässig.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Domain\Catalog;
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use App\Domain\Entitlement\Acquisition;
|
||||||
|
use App\Domain\Entitlement\GrantStatus;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class ArticleService
|
class ArticleService
|
||||||
@@ -34,22 +36,17 @@ public function publishRelease(
|
|||||||
throw new DomainRuleException('Ein neuer Stand braucht eine Einordnung, warum er zum selben Artikel gehört.');
|
throw new DomainRuleException('Ein neuer Stand braucht eine Einordnung, warum er zum selben Artikel gehört.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($root->status !== ContentVersionStatus::Bereit) {
|
$this->checkedRows($root);
|
||||||
throw new DomainRuleException('Ein Artikel-Stand kann nur eine bereitgestellte Fassung festschreiben.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows = $this->resolver->expand($root);
|
return DB::transaction(function () use ($article, $root, $classification, $changeNote): ArticleRelease {
|
||||||
|
$rows = $this->checkedRows($root);
|
||||||
if ($rows === []) {
|
$impact = $this->impact($article, count($rows));
|
||||||
throw new DomainRuleException('Ein Artikel-Stand braucht mindestens eine Inhaltsfassung.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return DB::transaction(function () use ($article, $root, $classification, $changeNote, $rows): ArticleRelease {
|
|
||||||
$release = $article->releases()->create([
|
$release = $article->releases()->create([
|
||||||
'number' => ((int) $article->releases()->max('number')) + 1,
|
'number' => ((int) $article->releases()->max('number')) + 1,
|
||||||
'classification_note' => $classification,
|
'classification_note' => $classification,
|
||||||
'status' => ReleaseStatus::Entwurf,
|
'status' => ReleaseStatus::Entwurf,
|
||||||
'change_note' => $changeNote,
|
'change_note' => $changeNote,
|
||||||
|
'impact_report' => $impact,
|
||||||
'root_element_version_id' => $root instanceof ContentElementVersion ? $root->id : null,
|
'root_element_version_id' => $root instanceof ContentElementVersion ? $root->id : null,
|
||||||
'root_composition_version_id' => $root instanceof CompositionVersion ? $root->id : null,
|
'root_composition_version_id' => $root instanceof CompositionVersion ? $root->id : null,
|
||||||
]);
|
]);
|
||||||
@@ -80,4 +77,115 @@ public function publishRelease(
|
|||||||
return $release->load('contents');
|
return $release->load('contents');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{fallback_number: int|null, holders: list<string>}
|
||||||
|
*/
|
||||||
|
public function withdraw(LicenseArticle $article, string $reason): array
|
||||||
|
{
|
||||||
|
$reason = trim($reason);
|
||||||
|
|
||||||
|
if ($reason === '') {
|
||||||
|
throw new DomainRuleException('Ein Rückzug braucht eine Begründung.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return DB::transaction(function () use ($article, $reason): array {
|
||||||
|
$article->refresh();
|
||||||
|
$current = $article->currentRelease;
|
||||||
|
|
||||||
|
if ($current === null || $current->status !== ReleaseStatus::Veroeffentlicht) {
|
||||||
|
throw new DomainRuleException('Zurückziehen lässt sich nur der aktuell veröffentlichte Stand.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$fallback = ArticleRelease::query()
|
||||||
|
->where('license_article_id', $article->id)
|
||||||
|
->where('status', ReleaseStatus::AbgeloestVerfuegbar)
|
||||||
|
->orderByDesc('number')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$current->status = ReleaseStatus::Gesperrt;
|
||||||
|
$current->block_reason = $reason;
|
||||||
|
$current->fallback_release_id = $fallback?->id;
|
||||||
|
$current->save();
|
||||||
|
|
||||||
|
if ($fallback instanceof ArticleRelease) {
|
||||||
|
$fallback->status = ReleaseStatus::Veroeffentlicht;
|
||||||
|
$fallback->save();
|
||||||
|
$article->current_release_id = $fallback->id;
|
||||||
|
} else {
|
||||||
|
$article->current_release_id = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$article->save();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'fallback_number' => $fallback?->number,
|
||||||
|
'holders' => Acquisition::query()
|
||||||
|
->whereHas('grants', fn ($query) => $query
|
||||||
|
->where('license_article_id', $article->id)
|
||||||
|
->where('status', GrantStatus::Aktiv))
|
||||||
|
->with('party')
|
||||||
|
->get()
|
||||||
|
->map(fn (Acquisition $acquisition): string => $acquisition->party->display_name)
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->all(),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{version_id: int, role: string, path: string}>
|
||||||
|
*/
|
||||||
|
private function checkedRows(ContentElementVersion|CompositionVersion $root): array
|
||||||
|
{
|
||||||
|
$root->refresh();
|
||||||
|
|
||||||
|
if ($root->status !== ContentVersionStatus::Bereit) {
|
||||||
|
throw new DomainRuleException('Ein Artikel-Stand kann nur eine bereitgestellte Fassung festschreiben.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows = $this->resolver->expand($root);
|
||||||
|
|
||||||
|
if ($rows === []) {
|
||||||
|
throw new DomainRuleException('Ein Artikel-Stand braucht mindestens eine Inhaltsfassung.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$blocked = ContentElementVersion::query()
|
||||||
|
->whereIn('id', array_column($rows, 'version_id'))
|
||||||
|
->where('status', '!=', ContentVersionStatus::Bereit->value)
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if ($blocked) {
|
||||||
|
throw new DomainRuleException('Eine gesperrte Inhaltsfassung kann nicht veröffentlicht werden.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{holders: int, offers: list<string>, contents: int, replaces_number: int|null}
|
||||||
|
*/
|
||||||
|
private function impact(LicenseArticle $article, int $contents): array
|
||||||
|
{
|
||||||
|
$article->loadMissing('currentRelease');
|
||||||
|
|
||||||
|
return [
|
||||||
|
'holders' => Acquisition::query()
|
||||||
|
->whereHas('grants', fn ($query) => $query
|
||||||
|
->where('license_article_id', $article->id)
|
||||||
|
->where('status', GrantStatus::Aktiv))
|
||||||
|
->distinct()
|
||||||
|
->count('party_id'),
|
||||||
|
'offers' => Offer::query()
|
||||||
|
->whereHas('versions', fn ($query) => $query
|
||||||
|
->where('status', OfferStatus::Aktiv)
|
||||||
|
->whereHas('resolvedScopes', fn ($scope) => $scope->where('license_article_id', $article->id)))
|
||||||
|
->orderBy('name')
|
||||||
|
->pluck('name')
|
||||||
|
->all(),
|
||||||
|
'contents' => $contents,
|
||||||
|
'replaces_number' => $article->currentRelease?->number,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,9 +26,24 @@ protected function casts(): array
|
|||||||
protected static function booted(): void
|
protected static function booted(): void
|
||||||
{
|
{
|
||||||
static::updating(function (CompositionVersion $version): void {
|
static::updating(function (CompositionVersion $version): void {
|
||||||
if (StatusValue::of($version->getOriginal('status')) === ContentVersionStatus::Bereit->value) {
|
$original = StatusValue::of($version->getOriginal('status'));
|
||||||
|
|
||||||
|
if (! in_array($original, [
|
||||||
|
ContentVersionStatus::Bereit->value,
|
||||||
|
ContentVersionStatus::Gesperrt->value,
|
||||||
|
], true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dirty = array_diff(array_keys($version->getDirty()), ['status', 'updated_at']);
|
||||||
|
|
||||||
|
if ($dirty !== [] || $original === ContentVersionStatus::Gesperrt->value) {
|
||||||
throw new DomainRuleException('Eine bestätigte Kompositionsfassung ist unveränderlich.');
|
throw new DomainRuleException('Eine bestätigte Kompositionsfassung ist unveränderlich.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StatusValue::of($version->status) !== ContentVersionStatus::Gesperrt->value) {
|
||||||
|
throw new DomainRuleException('Eine bestätigte Kompositionsfassung kann nur gesperrt werden.');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,24 @@ protected function casts(): array
|
|||||||
protected static function booted(): void
|
protected static function booted(): void
|
||||||
{
|
{
|
||||||
static::updating(function (ContentElementVersion $version): void {
|
static::updating(function (ContentElementVersion $version): void {
|
||||||
if (in_array(StatusValue::of($version->getOriginal('status')), [
|
$original = StatusValue::of($version->getOriginal('status'));
|
||||||
|
|
||||||
|
if (! in_array($original, [
|
||||||
ContentVersionStatus::Bereit->value,
|
ContentVersionStatus::Bereit->value,
|
||||||
ContentVersionStatus::Gesperrt->value,
|
ContentVersionStatus::Gesperrt->value,
|
||||||
], true)) {
|
], true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dirty = array_diff(array_keys($version->getDirty()), ['status', 'updated_at']);
|
||||||
|
|
||||||
|
if ($dirty !== [] || $original === ContentVersionStatus::Gesperrt->value) {
|
||||||
throw new DomainRuleException('Eine bereitgestellte Inhaltsfassung ist unveränderlich.');
|
throw new DomainRuleException('Eine bereitgestellte Inhaltsfassung ist unveränderlich.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StatusValue::of($version->status) !== ContentVersionStatus::Gesperrt->value) {
|
||||||
|
throw new DomainRuleException('Eine bereitgestellte Inhaltsfassung kann nur gesperrt werden.');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,20 @@ public function createElement(string $kind, string $outputClass, string $working
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function block(ContentElementVersion|CompositionVersion $version, string $reason): void
|
||||||
|
{
|
||||||
|
if (trim($reason) === '') {
|
||||||
|
throw new DomainRuleException('Eine Sperre braucht eine Begründung.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($version->status !== ContentVersionStatus::Bereit) {
|
||||||
|
throw new DomainRuleException('Nur eine bereitgestellte Fassung kann gesperrt werden.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$version->status = ContentVersionStatus::Gesperrt;
|
||||||
|
$version->save();
|
||||||
|
}
|
||||||
|
|
||||||
public function publishElementVersion(
|
public function publishElementVersion(
|
||||||
ContentElement $element,
|
ContentElement $element,
|
||||||
?string $body = null,
|
?string $body = null,
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ enum ReleaseStatus: string
|
|||||||
case Entwurf = 'entwurf';
|
case Entwurf = 'entwurf';
|
||||||
case Veroeffentlicht = 'veroeffentlicht';
|
case Veroeffentlicht = 'veroeffentlicht';
|
||||||
case AbgeloestVerfuegbar = 'abgeloest_verfuegbar';
|
case AbgeloestVerfuegbar = 'abgeloest_verfuegbar';
|
||||||
|
case Gesperrt = 'gesperrt';
|
||||||
}
|
}
|
||||||
@@ -44,19 +44,45 @@ protected function getHeaderActions(): array
|
|||||||
TextInput::make('change_note')->label('Änderungshinweis'),
|
TextInput::make('change_note')->label('Änderungshinweis'),
|
||||||
])
|
])
|
||||||
->action(function (array $data): void {
|
->action(function (array $data): void {
|
||||||
$this->report(function () use ($data): void {
|
$this->report(function () use ($data): string {
|
||||||
[$type, $id] = explode(':', $data['root'], 2);
|
[$type, $id] = explode(':', $data['root'], 2);
|
||||||
$root = $type === 'composition'
|
$root = $type === 'composition'
|
||||||
? CompositionVersion::query()->findOrFail($id)
|
? CompositionVersion::query()->findOrFail($id)
|
||||||
: ContentElementVersion::query()->findOrFail($id);
|
: ContentElementVersion::query()->findOrFail($id);
|
||||||
app(ArticleService::class)->publishRelease(
|
$release = app(ArticleService::class)->publishRelease(
|
||||||
LicenseArticle::query()->findOrFail($data['article_id']),
|
LicenseArticle::query()->findOrFail($data['article_id']),
|
||||||
$root,
|
$root,
|
||||||
$data['classification'],
|
$data['classification'],
|
||||||
$data['change_note'] ?? null,
|
$data['change_note'] ?? null,
|
||||||
);
|
);
|
||||||
|
$report = $release->impact_report ?? [];
|
||||||
|
$offers = $report['offers'] ?? [];
|
||||||
|
|
||||||
|
return 'Stand '.$release->number.' ist veröffentlicht. Inhalte: '.($report['contents'] ?? 0)
|
||||||
|
.', Inhaber: '.($report['holders'] ?? 0)
|
||||||
|
.', Angebote: '.(implode(', ', $offers) !== '' ? implode(', ', $offers) : 'keins').'.';
|
||||||
}, 'Der Artikel-Stand ist veröffentlicht.');
|
}, 'Der Artikel-Stand ist veröffentlicht.');
|
||||||
}),
|
}),
|
||||||
|
Action::make('withdraw')
|
||||||
|
->label('Stand zurückziehen')
|
||||||
|
->schema([
|
||||||
|
Select::make('article_id')->label('Artikel')->options(fn (): array => CatalogOptions::articles())->required(),
|
||||||
|
Textarea::make('reason')->label('Begründung')->required(),
|
||||||
|
])
|
||||||
|
->action(function (array $data): void {
|
||||||
|
$this->report(function () use ($data): string {
|
||||||
|
$result = app(ArticleService::class)->withdraw(
|
||||||
|
LicenseArticle::query()->findOrFail($data['article_id']),
|
||||||
|
$data['reason'],
|
||||||
|
);
|
||||||
|
$current = $result['fallback_number'] === null
|
||||||
|
? 'Es gibt keinen früheren Stand.'
|
||||||
|
: 'Aktuell ist wieder Stand '.$result['fallback_number'].'.';
|
||||||
|
$holders = $result['holders'] === [] ? 'niemand' : implode(', ', $result['holders']);
|
||||||
|
|
||||||
|
return 'Der Stand ist zurückgezogen. '.$current.' Betroffen: '.$holders.'.';
|
||||||
|
}, 'Der Stand ist zurückgezogen.');
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,8 +10,8 @@ trait ReportsDomainRules
|
|||||||
protected function report(callable $callback, string $success): void
|
protected function report(callable $callback, string $success): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$callback();
|
$detail = $callback();
|
||||||
Notification::make()->title($success)->success()->send();
|
Notification::make()->title(is_string($detail) && $detail !== '' ? $detail : $success)->success()->send();
|
||||||
} catch (DomainRuleException $exception) {
|
} catch (DomainRuleException $exception) {
|
||||||
Notification::make()->title($exception->getMessage())->danger()->send();
|
Notification::make()->title($exception->getMessage())->danger()->send();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('article_releases', function (Blueprint $table) {
|
||||||
|
$table->json('impact_report')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('article_releases', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('impact_report');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -6,7 +6,7 @@ ## Bedienbar
|
|||||||
|
|
||||||
- Öffentliche Seiten unter `/verwaltung` als Redakteur: Entwurf, Veröffentlichung, Wiederherstellung.
|
- Öffentliche Seiten unter `/verwaltung` als Redakteur: Entwurf, Veröffentlichung, Wiederherstellung.
|
||||||
- Inhaltselemente, Fassungen und Kompositionen als Redakteur. Eine Datei wird von der Queue nach `derived/` kopiert.
|
- Inhaltselemente, Fassungen und Kompositionen als Redakteur. Eine Datei wird von der Queue nach `derived/` kopiert.
|
||||||
- Lizenzartikel, verschachtelte Pakete, Rechteprofile und Angebote als Katalogverwalter.
|
- Lizenzartikel, verschachtelte Pakete, Rechteprofile und Angebote als Katalogverwalter. Ein neuer Stand zeigt Inhaber, Angebote und Inhaltszahl; ein Rückzug stellt den vorherigen Stand wieder her und nennt die Betroffenen.
|
||||||
- Manuelle Vergabe als Kundenbetreuung, am Benutzer in der Verwaltung.
|
- Manuelle Vergabe als Kundenbetreuung, am Benutzer in der Verwaltung.
|
||||||
- Registrierung, Anmeldung, kostenloser Abruf, Testkauf, Ablehnung und Widerruf im Mitgliederbereich.
|
- Registrierung, Anmeldung, kostenloser Abruf, Testkauf, Ablehnung und Widerruf im Mitgliederbereich.
|
||||||
- Bibliothek entscheidet je Abruf erneut. Filme mit Datei werden im Player geladen, Texte und PDF über einen kurz signierten Abruf.
|
- Bibliothek entscheidet je Abruf erneut. Filme mit Datei werden im Player geladen, Texte und PDF über einen kurz signierten Abruf.
|
||||||
|
|||||||
@@ -189,6 +189,63 @@ public function test_h_a_bundle_change_does_not_change_an_activated_offer(): voi
|
|||||||
$offer->save();
|
$offer->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_publication_records_impact_and_withdrawal_restores_the_previous_release(): void
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$articles = app(ArticleService::class);
|
||||||
|
$firstVersion = $this->element('Blatt', 'Fassung 1');
|
||||||
|
$article = $this->article('blatt');
|
||||||
|
$first = $articles->publishRelease($article, $firstVersion, 'Erste Einordnung.');
|
||||||
|
$article = $article->fresh();
|
||||||
|
$rights = $this->rights();
|
||||||
|
app(OfferService::class)->activate(
|
||||||
|
app(OfferService::class)->create('Blattangebot'),
|
||||||
|
[['target' => $article, 'rights' => $rights]],
|
||||||
|
);
|
||||||
|
$party = Party::query()->create([
|
||||||
|
'type' => PartyType::Person,
|
||||||
|
'display_name' => 'Mitglied Probe',
|
||||||
|
]);
|
||||||
|
$acquisition = Acquisition::query()->create([
|
||||||
|
'party_id' => $party->id,
|
||||||
|
'type' => AcquisitionType::FreierAbruf,
|
||||||
|
'reference_type' => 'offer',
|
||||||
|
'reference_id' => 1,
|
||||||
|
]);
|
||||||
|
Grant::query()->create([
|
||||||
|
'acquisition_id' => $acquisition->id,
|
||||||
|
'license_article_id' => $article->id,
|
||||||
|
'rights_profile_version_id' => $rights->id,
|
||||||
|
'rights_snapshot' => $rights->capabilities,
|
||||||
|
'release_at_grant_id' => $first->id,
|
||||||
|
'status' => GrantStatus::Aktiv,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$secondVersion = $content->publishElementVersion($firstVersion->element->fresh(), 'Fassung 2');
|
||||||
|
$second = $articles->publishRelease($article->fresh(), $secondVersion, 'Überarbeitung desselben Artikels.');
|
||||||
|
|
||||||
|
$this->assertSame(1, $second->impact_report['holders']);
|
||||||
|
$this->assertSame(['Blattangebot'], $second->impact_report['offers']);
|
||||||
|
$this->assertSame(1, $second->impact_report['replaces_number']);
|
||||||
|
|
||||||
|
$content->block($secondVersion, 'Fehlerhafte Fassung.');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$articles->publishRelease($article->fresh(), $secondVersion, 'Darf nicht erscheinen.');
|
||||||
|
$this->fail('Eine gesperrte Fassung darf nicht veröffentlicht werden.');
|
||||||
|
} catch (DomainRuleException) {
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSame($second->id, $article->fresh()->current_release_id);
|
||||||
|
|
||||||
|
$result = $articles->withdraw($article->fresh(), 'Die zweite Fassung ist fehlerhaft.');
|
||||||
|
|
||||||
|
$this->assertSame(1, $result['fallback_number']);
|
||||||
|
$this->assertSame(['Mitglied Probe'], $result['holders']);
|
||||||
|
$this->assertSame($first->id, $article->fresh()->current_release_id);
|
||||||
|
$this->assertSame('gesperrt', $second->fresh()->status->value);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_each_holder_gets_an_own_acquisition_and_one_grant_per_article(): void
|
public function test_each_holder_gets_an_own_acquisition_and_one_grant_per_article(): void
|
||||||
{
|
{
|
||||||
$article = $this->publishedArticle('frei', 'Kostenloses Blatt');
|
$article = $this->publishedArticle('frei', 'Kostenloses Blatt');
|
||||||
|
|||||||
Reference in new issue
Block a user