dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxAjax_submitter_test.php
Go to the documentation of this file.
1<?php
2
12
13$dbxRoot = dirname(__DIR__, 2);
14$ajaxFile = $dbxRoot . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'ajax.js';
15$confirmFile = $dbxRoot . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'confirm.js';
16$cartTemplate = $dbxRoot . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'dbxShop'
17 . DIRECTORY_SEPARATOR . 'tpl' . DIRECTORY_SEPARATOR . 'htm' . DIRECTORY_SEPARATOR . 'shop-cart-report.htm';
18$shopStartTemplate = $dbxRoot . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'dbxShop'
19 . DIRECTORY_SEPARATOR . 'tpl' . DIRECTORY_SEPARATOR . 'htm' . DIRECTORY_SEPARATOR . 'start.htm';
20$shopJsFile = $dbxRoot . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'dbxShop'
21 . DIRECTORY_SEPARATOR . 'design' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'shop.js';
22$shopServiceFile = $dbxRoot . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'dbxShop'
23 . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'dbxShopService.class.php';
24
25$ajax = is_file($ajaxFile) ? (string)file_get_contents($ajaxFile) : '';
26$confirm = is_file($confirmFile) ? (string)file_get_contents($confirmFile) : '';
27$cart = is_file($cartTemplate) ? (string)file_get_contents($cartTemplate) : '';
28$shopStart = is_file($shopStartTemplate) ? (string)file_get_contents($shopStartTemplate) : '';
29$shopJs = is_file($shopJsFile) ? (string)file_get_contents($shopJsFile) : '';
30$shopService = is_file($shopServiceFile) ? (string)file_get_contents($shopServiceFile) : '';
31$errors = array();
32
33if (strpos($ajax, 'submitSource: e.submitter || null') === false) {
34 $errors[] = 'ajax.js übernimmt SubmitEvent.submitter nicht.';
35}
36
37if (strpos($ajax, 'body.set(ctx.submitName, ctx.submitValue)') === false) {
38 $errors[] = 'ajax.js schreibt name/value des Submitters nicht in FormData.';
39}
40
41if (strpos($confirm, 'form.requestSubmit(source)') === false) {
42 $errors[] = 'confirm.js setzt bestätigte Formularaktionen nicht mit ihrem Submitter fort.';
43}
44
45if (strpos($confirm, 'dbx.ajax.run(ajaxRoot') !== false) {
46 $errors[] = 'confirm.js umgeht den regulären Formular-Submit.';
47}
48
49if (strpos($confirm, 'data-dbx-confirm-submitter') === false
50 || strpos($confirm, 'form.appendChild(submitProxy)') === false) {
51 $errors[] = 'confirm.js erhält name/value bestätigter Submitter nicht im Formular.';
52}
53
54if (strpos($cart, 'name="clear"') === false) {
55 $errors[] = 'Warenkorb-Template enthält name="clear" nicht.';
56}
57
58if (strpos($shopService, 'name="remove"') === false) {
59 $errors[] = 'Warenkorb-Report enthält name="remove" nicht.';
60}
61
62if (strpos($cart, 'data-dbx-shop-cart-count="{cart_count}"') === false
63 || strpos($shopService, "add_rep('cart_count'") === false) {
64 $errors[] = 'Warenkorb-Report veröffentlicht den aktuellen Menüzähler nicht.';
65}
66
67if (!preg_match('#dbxShop/design/js/shop\.js\?v=\d+#', $shopStart)
68 || strpos($shopJs, 'window.dbx.event.on("ajax:after"') === false) {
69 $errors[] = 'Shop-Menüzähler wird nach AJAX-Aktionen nicht synchronisiert.';
70}
71
72if ($errors !== array()) {
73 fwrite(STDERR, implode(PHP_EOL, $errors) . PHP_EOL);
74 exit(1);
75}
76
77echo "OK dbxAjax_submitter_test" . PHP_EOL;
$dbxRoot
Regressionstest für benannte Submit-Schaltflächen in AJAX-Formularen.
exit
Definition index.php:146