Pflege Übungen im Aufbauarbeitsplatz und weise Verwendung und Sperrfolgen nach
CI Feature / test (push) Successful in 2m34s
CI Feature / test (push) Successful in 2m34s
Eigener Eintrag Übungen unter Inhalte (Bestand, Anlegen, gemeinsamer Aufbau mit Varianten, Verwendung und Variantenauswahl im Modul und Programm), Verwendungsnachweis über verschachtelte und ältere Stände, Auswirkungsbericht einer Mediensperre, gesperrte Bestandteile verhindern die Angebotsaktivierung, Vorschaubilder gesperrter Medien werden nicht mehr ausgeliefert, Rückfalltest gegen die Daten des neuen Stands. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d1f97a351a
commit
bbee288e69
22 files changed
+1104
-26
No files matched your search
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Filament\Resources\Courses\Pages\EditCourse;
|
||||
use App\Filament\Resources\Exercises\Pages\EditExercise;
|
||||
use App\Http\SignedLink;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Rückfalltest: Dieser Test läuft im VORHERIGEN Programmstand (Teil 0) gegen eine Datenbank, die der NEUE Stand erzeugt
|
||||
* hat (Übung mit zwei Varianten, Modul mit Variante A, Programm mit Variante B, verkauft). Der Rückfall setzt nur den
|
||||
* Code zurück; die Daten bleiben. Der alte Stand darf nicht abstürzen, keine ungewählte Variante und keine Übung
|
||||
* offenlegen und beim Bearbeiten nichts verlieren.
|
||||
*/
|
||||
class RueckfallGegenNeueDatenTest extends TestCase
|
||||
{
|
||||
/** @var array<string, int> */
|
||||
private array $ids;
|
||||
|
||||
private string $file;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->file = sys_get_temp_dir().'/rueckfall-'.uniqid().'.sqlite';
|
||||
copy((string) getenv('RUECKFALL_DB'), $this->file);
|
||||
config(['database.connections.sqlite.database' => $this->file]);
|
||||
DB::purge('sqlite');
|
||||
$this->ids = json_decode((string) file_get_contents((string) getenv('RUECKFALL_JSON')), true, 512, JSON_THROW_ON_ERROR);
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
DB::purge('sqlite');
|
||||
@unlink($this->file);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_the_stored_exercise_is_a_kind_the_previous_state_does_not_know(): void
|
||||
{
|
||||
$this->assertSame(1, DB::table('compositions')->where('kind', 'exercise')->count());
|
||||
$this->assertNull(Composition::query()->find($this->ids['exercise_composition']));
|
||||
}
|
||||
|
||||
public function test_the_member_area_neither_crashes_nor_leaks(): void
|
||||
{
|
||||
$member = User::query()->findOrFail($this->ids['member']);
|
||||
|
||||
$this->actingAs($member)->get(route('member.library'))->assertOk()->assertSee('Modul Stopp')->assertSee('Programm Stopp');
|
||||
|
||||
foreach (['module_composition', 'program_composition'] as $key) {
|
||||
$this->actingAs($member)
|
||||
->get(route('member.program', $this->ids[$key]))
|
||||
->assertOk()
|
||||
->assertDontSee('Stopp sagen')
|
||||
->assertDontSee('Variante')
|
||||
->assertDontSee('Film A')
|
||||
->assertDontSee('Durchführung');
|
||||
}
|
||||
|
||||
$this->actingAs($member)->get(route('member.program', $this->ids['exercise_composition']))->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_only_the_chosen_variant_of_each_stand_is_delivered(): void
|
||||
{
|
||||
$member = User::query()->findOrFail($this->ids['member']);
|
||||
|
||||
$this->actingAs($member)
|
||||
->get(route('member.article', $this->ids['module_article']))
|
||||
->assertOk()
|
||||
->assertSee('Film A')
|
||||
->assertSee('Durchführung A')
|
||||
->assertDontSee('Durchführung B')
|
||||
->assertDontSee('Arbeitsblatt B');
|
||||
|
||||
$this->actingAs($member)
|
||||
->get(route('member.article', $this->ids['program_article']))
|
||||
->assertOk()
|
||||
->assertSee('Durchführung B')
|
||||
->assertDontSee('Film A')
|
||||
->assertDontSee('Durchführung A');
|
||||
|
||||
$unchosen = SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
'article' => $this->ids['module_article'],
|
||||
'release' => $this->ids['module_release'],
|
||||
'version' => $this->ids['film_b_text'],
|
||||
'action' => 'ansehen',
|
||||
'reader' => $member->id,
|
||||
]);
|
||||
$this->actingAs($member)->get($unchosen)->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_the_previous_editors_are_read_only_and_lose_nothing(): void
|
||||
{
|
||||
$staff = User::factory()->redakteur()->create();
|
||||
$staff->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
$membersBefore = DB::table('composition_members')->count();
|
||||
$versionsBefore = DB::table('composition_versions')->count();
|
||||
|
||||
foreach ([[EditExercise::class, 'module_composition'], [EditCourse::class, 'program_composition']] as [$page, $key]) {
|
||||
$component = Livewire::actingAs($staff, 'staff')
|
||||
->test($page, ['record' => $this->ids[$key]])
|
||||
->assertOk()
|
||||
->assertSee('neueren Programmversion');
|
||||
|
||||
$this->assertNotNull($component->instance()->schreibschutz());
|
||||
$component->call('saveDraft')->call('armRelease')->call('discardDraft');
|
||||
$this->assertFalse($component->instance()->publishRevision());
|
||||
}
|
||||
|
||||
$this->assertSame($membersBefore, DB::table('composition_members')->count());
|
||||
$this->assertSame($versionsBefore, DB::table('composition_versions')->count());
|
||||
$this->assertSame(0, DB::table('compositions')->whereNotNull('working_draft')->count());
|
||||
}
|
||||
|
||||
public function test_the_previous_state_refuses_a_new_stand_that_would_drop_the_exercise(): void
|
||||
{
|
||||
$article = LicenseArticle::query()->findOrFail($this->ids['module_article']);
|
||||
$release = ArticleRelease::query()->findOrFail($this->ids['module_release']);
|
||||
$releases = $article->releases()->count();
|
||||
|
||||
try {
|
||||
app(ArticleService::class)->publishRelease($article, $release->rootCompositionVersion, 'Neuer Stand im alten Programmstand.');
|
||||
$this->fail('Der alte Stand darf keinen Stand mit Übung veröffentlichen.');
|
||||
} catch (DomainRuleException $exception) {
|
||||
$this->assertStringContainsString('Programmstand', $exception->getMessage());
|
||||
}
|
||||
|
||||
$this->assertSame($releases, $article->releases()->count());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user