dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxKiCmsHeroContract_test.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
4require_once dirname(__DIR__) . '/include/dbxKiCmsService.class.php';
5
6$failures = array();
7$assert = static function (bool $condition, string $message) use (&$failures): void {
8 if (!$condition) {
9 $failures[] = $message;
10 }
11};
12
13$class = new ReflectionClass(\dbx\dbxKi\dbxKiCmsService::class);
14$service = $class->newInstanceWithoutConstructor();
15$validate = $class->getMethod('assert_no_fake_inline_hero');
16$validate->setAccessible(true);
17
18$fakeHero = '<div class="position-relative"><img data-cms-media-id="166" src="index.php?dbx_mid=166">'
19 . '<div class="position-absolute top-0 start-0 w-100 h-100"><h2>Eine Plattform</h2>'
20 . '<p>Dieser umfangreiche Text liegt über dem Bild und bildet damit fälschlich einen Hero im normalen Inhalt nach.</p>'
21 . '<a href="demo">Demo ansehen</a></div></div><p>Body</p>';
22$rejected = false;
23try {
25} catch (ReflectionException $error) {
26 throw $error;
27} catch (Throwable $error) {
28 $cause = $error instanceof ReflectionException ? $error : ($error->getPrevious() ?: $error);
29 $rejected = str_contains($cause->getMessage(), 'CMS-Hero')
30 || str_contains($error->getMessage(), 'CMS-Hero');
31}
32$assert($rejected, 'dbxKi accepts an inline fake Hero at the start of content.');
33
34$realHero = '<div class="dbx-home-hero-copy"><h2>Eine Plattform</h2><p>Hero-Text ohne Inline-Bild.</p></div>'
35 . '<hr class="dbx-cms-marker" data-dbx-marker="dbx:hero"><p>Body</p>';
37try {
39} catch (Throwable $error) {
40 $validHeroAccepted = false;
41}
42$assert($validHeroAccepted, 'dbxKi rejects the native Hero marker structure.');
43
44$cardWithBadge = '<div class="card position-relative"><img class="card-img-top" data-cms-media-id="42" src="index.php?dbx_mid=42">'
45 . '<span class="position-absolute badge">Neu</span><div class="card-body"><p>Produkt</p></div></div>';
47try {
49} catch (Throwable $error) {
50 $cardAccepted = false;
51}
52$assert($cardAccepted, 'dbxKi incorrectly rejects a small absolute card badge.');
53
54$workflow = $class->getMethod('page_workflows');
55$workflow->setAccessible(true);
56$workflowText = json_encode($workflow->invoke($service), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
57$contract = $class->getMethod('content_contract');
58$contract->setAccessible(true);
59$contractText = json_encode($contract->invoke($service), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
61 str_contains((string)$workflowText, 'Inline-Schein-Hero')
62 && str_contains((string)$workflowText, 'slot=hero')
63 && str_contains((string)$contractText, 'dbx:hero'),
64 'The dbxKi CMS contract does not document the native Hero workflow.'
65);
66
67if ($failures !== array()) {
68 fwrite(STDERR, "FAIL\n- " . implode("\n- ", $failures) . "\n");
69 exit(1);
70}
71
72echo "OK dbxKi enforces the native CMS Hero workflow.\n";
exit
Definition index.php:146
DBX schema administration.