dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxContent_cms_hero_contract_test.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
4require_once dirname(__DIR__, 2) . '/dbxContent/include/dbxContentRenderer.class.php';
5
7
8$base = dirname(__DIR__, 4);
9$failures = array();
10$assert = static function (bool $condition, string $message) use (&$failures): void {
11 if (!$condition) $failures[] = $message;
12};
13
14$cmsJs = (string)file_get_contents($base . '/dbx/js/lib/cms.js');
16 str_contains($cmsJs, '{ label: "Hero", marker: "dbx:hero" }'),
17 'Im Editor-Menü fehlt der kanonische Hero-Marker.'
18);
20 !str_contains($cmsJs, '"dbx:hero": "Hero-Text"')
21 && !str_contains($cmsJs, '{ label: "Hero-Text", marker: "dbx:hero" }'),
22 'Der Editor bietet Hero noch als reinen Textbereich an.'
23);
25 str_contains($cmsJs, 'function dedupeSingletonMarkers(')
26 && str_contains($cmsJs, 'if (name !== "hero") return;'),
27 'Mehrere Hero-Marker werden im Editor nicht auf einen Marker normalisiert.'
28);
29
30$heroTemplates = glob($base . '/dbx/modules/dbxContent/tpl/htm/c-*hero*.htm') ?: array();
31$assert(count($heroTemplates) >= 4, 'Die erwarteten c-*-Hero-Templates fehlen.');
32foreach ($heroTemplates as $templateFile) {
33 $html = (string)file_get_contents($templateFile);
34 $assert(str_contains($html, '{cms:hero}'), basename($templateFile) . ' enthält keinen Hero-Slot.');
35 $assert(!str_contains($html, 'hero_text') && !str_contains($html, 'hero-text'), basename($templateFile) . ' enthält noch einen getrennten Hero-Text-Slot.');
36 $assert(substr_count($html, '{cms:hero}') === 1, basename($templateFile) . ' muss genau einen Hero-Slot enthalten.');
37}
38
39$sections = (string)file_get_contents($base . '/dbx/modules/dbxContent_admin/include/dbxContent_sections.class.php');
40$assert(!str_contains($sections, '{cms:hero_text}'), 'Neue Content-Templates erzeugen noch cms:hero_text.');
41
42$reflection = new ReflectionClass(dbxContentRenderer::class);
43$renderer = $reflection->newInstanceWithoutConstructor();
44$detect = $reflection->getMethod('detect_template_slots');
45$detect->setAccessible(true);
46$parse = $reflection->getMethod('parse_content');
47$parse->setAccessible(true);
48
49$slots = $detect->invoke($renderer, '<section class="cms-hero"><div class="hero">{cms:hero}</div></section><main>{cms:col1}</main>');
50$assert(!empty($slots['media']['hero']), 'cms:hero lädt das zugeordnete Hero-Medium nicht.');
51$assert(!empty($slots['content']['hero']), 'cms:hero nimmt keinen freien Hero-Inhalt auf.');
52
53$content = '<h2>Freier Hero</h2><figure><video src="hero.mp4"></video></figure>'
54 . '<hr class="dbx-cms-marker dbx-cms-marker-hero_text" data-dbx-marker="dbx:hero_text">'
55 . '<p>Seiteninhalt</p>';
57$assert(str_contains((string)($parsed['hero'] ?? ''), 'Freier Hero'), 'Hero-Überschrift wurde nicht dem Hero zugeordnet.');
58$assert(str_contains((string)($parsed['hero'] ?? ''), '<video'), 'Ein Video kann nicht als freier Hero-Inhalt verwendet werden.');
59$assert(str_contains((string)($parsed['body'] ?? ''), 'Seiteninhalt'), 'Inhalt hinter dem Hero-Marker fehlt im Body.');
60$assert(!array_key_exists('hero_text', $parsed), 'Der Renderer liefert weiterhin einen getrennten hero_text-Bereich.');
61
62foreach (array('dbxapp', 'dbxdocs', 'steal') as $design) {
63 $css = (string)file_get_contents($base . '/dbx/design/' . $design . '/css/c-content-frame.css');
64 $assert(str_contains($css, '.hero-content'), 'Universelles Hero-Content-Styling fehlt in ' . $design . '.');
65 $assert(!str_contains($css, '.hero-text') && !str_contains($css, 'cms-hero-text'), 'Veraltetes Hero-Text-Styling in ' . $design . '.');
66}
67
68if ($failures !== array()) {
69 fwrite(STDERR, "FAIL\n- " . implode("\n- ", $failures) . "\n");
70 exit(1);
71}
72
73echo "OK CMS uses one universal Hero marker for text, image and video content.\n";
foreach($heroTemplates as $templateFile) $sections
if(trim($second) !=='second') $design
exit
Definition index.php:146