[TASK] Integrate tests for DataHandler hook invocations
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / DataHandler / Fixtures / HookFixture.php
1 <?php
2 declare(strict_types=1);
3 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\Fixtures;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 use TYPO3\CMS\Core\DataHandling\DataHandler;
19 use TYPO3\CMS\Core\SingletonInterface;
20
21 /**
22 * Class for testing execution of DataHandler hook invocations.
23 */
24 class HookFixture implements SingletonInterface
25 {
26 /**
27 * @var array[]
28 */
29 protected $invocations = [];
30
31 /**
32 * Purges the state of this singleton instance
33 */
34 public function purge()
35 {
36 $this->invocations = [];
37 }
38
39 /**
40 * @param string $methodName
41 * @return array|null
42 */
43 public function findInvocationsByMethodName(string $methodName)
44 {
45 return $this->invocations[$methodName] ?? null;
46 }
47
48 /**
49 * @param DataHandler $dataHandler
50 */
51 public function processDatamap_beforeStart(DataHandler $dataHandler)
52 {
53 $this->invocations[__FUNCTION__][] = true;
54 }
55
56 /**
57 * @param array $fieldArray
58 * @param string $table
59 * @param string|int $id
60 * @param DataHandler $dataHandler
61 */
62 public function processDatamap_preProcessFieldArray(array $fieldArray, string $table, $id, DataHandler $dataHandler)
63 {
64 $this->invocations[__FUNCTION__][] = [
65 'fieldArray' => $fieldArray,
66 'table' => $table,
67 'id' => $id,
68 ];
69 }
70
71 /**
72 * @param string $status
73 * @param string $table
74 * @param string|int $id
75 * @param array $fieldArray
76 * @param DataHandler $dataHandler
77 */
78 public function processDatamap_postProcessFieldArray(string $status, string $table, $id, array $fieldArray, DataHandler $dataHandler)
79 {
80 $this->invocations[__FUNCTION__][] = [
81 'status' => $status,
82 'table' => $table,
83 'id' => $id,
84 'fieldArray' => $fieldArray,
85 ];
86 }
87
88 /**
89 * @param string $status
90 * @param string $table
91 * @param string|int $id
92 * @param array $fieldArray
93 * @param DataHandler $dataHandler
94 */
95 public function processDatamap_afterDatabaseOperations(string $status, string $table, $id, array $fieldArray, DataHandler $dataHandler)
96 {
97 $this->invocations[__FUNCTION__][] = [
98 'status' => $status,
99 'table' => $table,
100 'id' => $id,
101 'fieldArray' => $fieldArray,
102 ];
103 }
104
105 /**
106 * @param DataHandler $dataHandler
107 */
108 public function processDatamap_afterAllOperations(DataHandler $dataHandler)
109 {
110 $this->invocations[__FUNCTION__][] = true;
111 }
112
113 /**
114 * @param DataHandler $dataHandler
115 */
116 public function processCmdmap_beforeStart(DataHandler $dataHandler)
117 {
118 $this->invocations[__FUNCTION__][] = true;
119 }
120
121 /**
122 * @param string $command
123 * @param string $table
124 * @param string|int $id
125 * @param mixed $value
126 * @param DataHandler $dataHandler
127 * @param bool|string $pasteUpdate
128 */
129 public function processCmdmap_preProcess(string $command, string $table, $id, $value, DataHandler $dataHandler, $pasteUpdate)
130 {
131 $this->invocations[__FUNCTION__][] = [
132 'command' => $command,
133 'table' => $table,
134 'id' => $id,
135 'value' => $value,
136 'pasteUpdate' => $pasteUpdate,
137 ];
138 }
139
140 /**
141 * @param string $command
142 * @param string $table
143 * @param string|int $id
144 * @param mixed $value
145 * @param bool $commandIsProcessed
146 * @param DataHandler $dataHandler
147 * @param bool|string $pasteUpdate
148 */
149 public function processCmdmap(string $command, string $table, $id, $value, bool $commandIsProcessed, DataHandler $dataHandler, $pasteUpdate)
150 {
151 $this->invocations[__FUNCTION__][] = [
152 'command' => $command,
153 'table' => $table,
154 'id' => $id,
155 'value' => $value,
156 'commandIsProcessed' => $commandIsProcessed,
157 'pasteUpdate' => $pasteUpdate,
158 ];
159 }
160
161 /**
162 * @param string $command
163 * @param string $table
164 * @param string|int $id
165 * @param mixed $value
166 * @param DataHandler $dataHandler
167 * @param bool|string $pasteUpdate
168 * @param bool|string $pasteDatamap
169 */
170 public function processCmdmap_postProcess(string $command, string $table, $id, $value, DataHandler $dataHandler, $pasteUpdate, $pasteDatamap)
171 {
172 $this->invocations[__FUNCTION__][] = [
173 'command' => $command,
174 'table' => $table,
175 'id' => $id,
176 'value' => $value,
177 'pasteUpdate' => $pasteUpdate,
178 'pasteDatamap' => $pasteDatamap,
179 ];
180 }
181
182 /**
183 * @param DataHandler $dataHandler
184 */
185 public function processCmdmap_afterFinish(DataHandler $dataHandler)
186 {
187 $this->invocations[__FUNCTION__][] = true;
188 }
189 }