dbxapp
4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
dbxapp.de
Portal
Start
Anwender
Entwickler
KI-Bereiche
Loading...
Searching...
No Matches
dbxContent_cms_hero_contract_test.php
Go to the documentation of this file.
1
<?php
2
declare(strict_types=1);
3
4
require_once dirname(__DIR__, 2) .
'/dbxContent/include/dbxContentRenderer.class.php'
;
5
6
use
dbx\dbxContent\dbxContentRenderer
;
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'
);
15
$assert
(
16
str_contains(
$cmsJs
,
'{ label: "Hero", marker: "dbx:hero" }'
),
17
'Im Editor-Menü fehlt der kanonische Hero-Marker.'
18
);
19
$assert
(
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
);
24
$assert
(
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.'
);
32
foreach
(
$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>'
;
56
$parsed
=
$parse
->invoke(
$renderer
,
$content
,
$slots
);
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
62
foreach
(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
68
if
(
$failures
!== array()) {
69
fwrite(STDERR,
"FAIL\n- "
. implode(
"\n- "
,
$failures
) .
"\n"
);
70
exit
(1);
71
}
72
73
echo
"OK CMS uses one universal Hero marker for text, image and video content.\n"
;
dbx\dbxContent\dbxContentRenderer
Definition
dbxContentRenderer.class.php:7
$failures
$failures
Definition
db_access_boundary_test.php:5
$base
$base
Definition
dbxApi_paths_test.php:11
$assert
$assert
Definition
dbxCmsEditorPerformance_contract_test.php:8
$cmsJs
$cmsJs
Definition
dbxCmsLazyTreePerformance_contract_test.php:10
$renderer
$renderer
Definition
dbxCmsVideoSizing_contract_test.php:12
$reflection
$reflection
Definition
dbxContent_cms_hero_contract_test.php:42
$assert
$assert
Definition
dbxContent_cms_hero_contract_test.php:10
$slots
$slots
Definition
dbxContent_cms_hero_contract_test.php:49
$heroTemplates
$heroTemplates
Definition
dbxContent_cms_hero_contract_test.php:30
$parsed
$parsed
Definition
dbxContent_cms_hero_contract_test.php:56
$sections
foreach($heroTemplates as $templateFile) $sections
Definition
dbxContent_cms_hero_contract_test.php:39
$detect
$detect
Definition
dbxContent_cms_hero_contract_test.php:44
$parse
$parse
Definition
dbxContent_cms_hero_contract_test.php:46
$css
$css
Definition
dbxDashboard_error_log_contract_test.php:17
$content
$content
Definition
dbxForm_try_count_test.php:72
$html
$html
Definition
dbxSearchTemplate_test.php:21
$templateFile
$templateFile
Definition
dbxStealSurfaceContract_test.php:13
$design
if(trim($second) !=='second') $design
Definition
dbxTPL_raw_cache_test.php:118
exit
exit
Definition
index.php:146
dbx
modules
dbxContent_admin
tests
dbxContent_cms_hero_contract_test.php
Generated by
1.17.0