dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
myInvoices_contract_test.php
Go to the documentation of this file.
1<?php
5
6$module = dirname(__DIR__);
7$fail = function (string $message, int $code): void {
8 fwrite(STDERR, "FAIL: $message\n");
9 exit($code);
10};
11
12$required = array(
13 'myInvoices.class.php',
14 'cfg/config.php',
15 'dd/invoice.dd.php',
16 'dd/invoiceItem.dd.php',
17 'fd/invoice-form.fd.php',
18 'fd/rpt-invoice-selection.fd.php',
19 'include/myInvoicesFixtures.class.php',
20 'include/myInvoicesService.class.php',
21 'tpl/htm/invoice-form.htm',
22 'tpl/htm/invoice-report.htm',
23 'tpl/htm/invoice-items-report.htm',
24 'tpl/htm/invoice-row-action.htm',
25 'tpl/htm/invoice-install.htm',
26 'tools/install_demo.php',
27 'tests/myInvoices_integration_test.php',
28 'README.md',
29);
30foreach ($required as $relative) {
31 if (!is_file($module . '/' . $relative)) {
32 $fail('Datei fehlt: ' . $relative, 1);
33 }
34}
35
36foreach (array('dd/invoice.dd.php', 'dd/invoiceItem.dd.php') as $relative) {
37 $source = (string)file_get_contents($module . '/' . $relative);
38 if (!preg_match('/\$table\‍[\'trace\'\‍]\s*=\s*\'0\';/', $source)) {
39 $fail($relative . ': produktives DD muss trace=0 verwenden.', 2);
40 }
41 if (strpos($source, '$addField') !== false) {
42 $fail($relative . ': DD-Felder muessen explizit definiert sein.', 2);
43 }
44 foreach (array(
45 'TABLE',
46 'FIELDS',
47 'INDEXES',
48 "\$field['tooltip']",
49 "\$field['js']",
50 "\$field['prompt']",
51 '$fields[]=$field;',
52 '$indexes[]=$index;',
53 ) as $requiredDdPart) {
54 if (strpos($source, $requiredDdPart) === false) {
55 $fail(
56 $relative . ': expliziter DD-Bestandteil fehlt: '
57 . $requiredDdPart,
58 2
59 );
60 }
61 }
62}
63
65foreach (array(
66 'myInvoices.class.php',
67 'include/myInvoicesFixtures.class.php',
68 'include/myInvoicesService.class.php',
69) as $relative) {
70 $source = (string)file_get_contents($module . '/' . $relative);
71 $phpSources .= "\n" . $source;
72 try {
73 token_get_all($source, TOKEN_PARSE);
74 } catch (ParseError $exception) {
75 $fail($relative . ': ' . $exception->getMessage(), 3);
76 }
77}
78
79foreach (array(
80 '/\bPDO\b/',
81 '/\bmysqli?_/',
82 '/->(?:query|exec|prepare)\s*\‍(/',
83 '/\b(?:SELECT|INSERT|UPDATE|DELETE)\s+(?:FROM|INTO|SET)\b/i',
84) as $forbidden) {
85 if (preg_match($forbidden, $phpSources)) {
86 $fail('Direkter Datenbankzugriff gefunden: ' . $forbidden, 4);
87 }
88}
89
90if (preg_match(
91 '/private function (?:db|tpl|form|report)\s*\‍([^)]*\‍)\s*\{'
92 . '\s*return\s+dbx\‍(\‍)->get_(?:system|include)_obj/s',
94)) {
95 $fail('Unnötiger dbx-Wrapper gefunden.', 5);
96}
97
98$fixtureSource = (string)file_get_contents(
99 $module . '/include/myInvoicesFixtures.class.php'
100);
101foreach (array(
102 'create_date',
103 'create_uid',
104 'update_date',
105 'update_uid',
106 'owner',
107) as $systemField) {
108 if (preg_match(
109 '/[\'"]' . preg_quote($systemField, '/') . '[\'"]\s*=>/',
111 )) {
112 $fail(
113 'Fixture setzt dbxDB-Systemfeld manuell: ' . $systemField,
114 6
115 );
116 }
117}
118
119$service = (string)file_get_contents(
120 $module . '/include/myInvoicesService.class.php'
121);
122foreach (array(
123 "get_system_obj('dbxDB')",
124 "get_system_obj('dbxForm')",
125 "get_system_obj('dbxReport')",
126 "get_system_obj('dbxTPL')",
127 'invoice_report_next_record',
128 'invoice_items_report_next_record',
129 "add_rep(\n 'report_total'",
130 '[modul=myInvoices]dbx_run1=positions&invoice_id=',
131 'action_url',
132 '->begin(self::INVOICE_DD)',
133 '->commit(self::INVOICE_DD)',
134 '->rollback(self::INVOICE_DD)',
135) as $requiredSource) {
136 if (strpos($service, $requiredSource) === false) {
137 $fail('Servicevertrag fehlt: ' . $requiredSource, 7);
138 }
139}
140
141$config = (string)file_get_contents($module . '/cfg/config.php');
142if (strpos($config, 'action_routes') !== false) {
143 $fail('Automatisch erkennbare RID-Aktion ist noch manuell konfiguriert.', 8);
144}
145if (strpos($service, 'check_action_token') !== false
146 || strpos($service, 'action_token(') !== false
147) {
148 $fail('Service verwaltet Action-Tokens noch manuell.', 8);
149}
150foreach (array(
151 'set_callback_owner(',
152 'set_next_record_callback(',
153 'set_footer_callback(',
154 'renderInvoiceFooter',
155 'renderItemFooter',
156 'str_replace(',
157) as $unnecessaryCallbackCode) {
158 if (strpos($service, $unnecessaryCallbackCode) !== false) {
159 $fail(
160 'Service umgeht Callback-Defaults: ' . $unnecessaryCallbackCode,
161 8
162 );
163 }
164}
165
166$itemTemplate = (string)file_get_contents(
167 $module . '/tpl/htm/invoice-items-report.htm'
168);
169if (stripos($itemTemplate, '<form') !== false) {
170 $fail('Eingebetteter Positionsreport enthält ein Formular.', 8);
171}
172foreach (array(
173 '<hr class="dbx_split">',
174 '{rpt:colspan}',
175 '{report_total}',
176) as $requiredTemplate) {
177 if (strpos($itemTemplate, $requiredTemplate) === false) {
178 $fail('Positionsreport-Vertrag fehlt: ' . $requiredTemplate, 9);
179 }
180}
181
182$actionTemplate = (string)file_get_contents(
183 $module . '/tpl/htm/invoice-row-action.htm'
184);
185foreach (array('dbxAjax', 'dbxConfirm', 'data-confirm-buttons="yesno"') as $part) {
186 if (strpos($actionTemplate, $part) === false) {
187 $fail('Action-Vertrag fehlt: ' . $part, 10);
188 }
189}
190
191echo "OK myInvoices architecture contract\n";
if($resolved !==$expectedBase . 'files/test/') $config
exit
Definition index.php:146
if(strpos($config, 'action_routes') !==false) if(strpos( $service, 'check_action_token') !==false||strpos( $service, 'action_token(') !==false) foreach(array('set_callback_owner(', 'set_next_record_callback(', 'set_footer_callback(', 'renderInvoiceFooter', 'renderItemFooter', 'str_replace(',) as $unnecessaryCallbackCode) $itemTemplate
foreach( $required as $relative) foreach(array('dd/invoice.dd.php', 'dd/invoiceItem.dd.php') as $relative) $phpSources
foreach(array('myInvoices.class.php', 'include/myInvoicesFixtures.class.php', 'include/myInvoicesService.class.php',) as $relative) foreach(array('/\bPDO\b/', '/\bmysqli?_/', '/->(?:query|exec|prepare)\s *\‍(/', '/\b(?:SELECT|INSERT|UPDATE|DELETE)\s+(?:FROM|INTO|SET)\b/i',) as $forbidden) if(preg_match('/private function(?:db|tpl|form|report)\s *\‍( $fixtureSource[^)] *\‍)\s *\{' . '\s *return\s+dbx\‍(\‍) ->get_(?:system|include) _obj/s', $phpSources))
if(stripos( $itemTemplate, '< form') !==false) foreach(array('< hr class="dbx_split">', '{rpt:colspan}', '{report_total}',) as $requiredTemplate) $actionTemplate