10-04-2026

This commit is contained in:
Kevin Adametz 2026-04-10 17:18:17 +02:00
parent 4d6b4930b2
commit 4bb89aad8c
836 changed files with 52961 additions and 5950 deletions

View file

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
use App\Services\CmsFluxEditorHtmlTransformer;
test('toEditor wandelt span text-secondary in mark um', function () {
$html = '<p>Hallo <span class="text-secondary">Akzent</span>!</p>';
$out = CmsFluxEditorHtmlTransformer::toEditor($html);
expect($out)->toContain('<mark>');
expect($out)->toContain('Akzent');
expect($out)->not->toContain('text-secondary');
});
test('fromEditor wandelt mark in span text-secondary um', function () {
$html = '<p>Hallo <mark>Akzent</mark>!</p>';
$out = CmsFluxEditorHtmlTransformer::fromEditor($html);
expect($out)->toContain('class="text-secondary"');
expect($out)->toContain('Akzent');
expect($out)->not->toContain('<mark>');
});
test('Roundtrip erhält verschachtelte Formatierung', function () {
$original = '<p><span class="text-secondary"><strong>Fett</strong> und normal</span></p>';
$editor = CmsFluxEditorHtmlTransformer::toEditor($original);
$saved = CmsFluxEditorHtmlTransformer::fromEditor($editor);
expect($saved)->toContain('text-secondary');
expect($saved)->toContain('<strong>Fett</strong>');
});
test('JSON-Rich-Text-Felder werden für den Editor umgewandelt', function () {
$items = [
[
'title' => 'x',
'description' => '<p><span class="text-secondary">Hinweis</span></p>',
],
];
$out = CmsFluxEditorHtmlTransformer::toEditorJsonItems($items, false);
expect($out[0]['description'])->toContain('<mark>');
});
test('JSON-Rich-Text-Felder werden beim Speichern zurückgewandelt', function () {
$items = [
[
'description' => '<p><mark>Hinweis</mark></p>',
],
];
$out = CmsFluxEditorHtmlTransformer::fromEditorJsonItems($items, false);
expect($out[0]['description'])->toContain('text-secondary');
});