Passed
Push — main ( 273db0...683317 )
by Thierry
03:54
created
jaxon-core/src/Plugin/Code/CodeGenerator.php 2 patches
Switch Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -31,75 +31,75 @@  discard block
 block discarded – undo
31 31
 
32 32
 class CodeGenerator
33 33
 {
34
-    /**
34
+/**
35 35
      * @var AssetManager
36 36
      */
37
-    private $xAssetManager;
37
+private $xAssetManager;
38 38
 
39
-    /**
39
+/**
40 40
      * The classes that generate code
41 41
      *
42 42
      * @var array<string>
43 43
      */
44
-    protected $aCodeGenerators = [];
44
+protected $aCodeGenerators = [];
45 45
 
46
-    /**
46
+/**
47 47
      * @var string
48 48
      */
49
-    protected $sJsOptions;
49
+protected $sJsOptions;
50 50
 
51
-    /**
51
+/**
52 52
      * @var array
53 53
      */
54
-    protected $aCss = [];
54
+protected $aCss = [];
55 55
 
56
-    /**
56
+/**
57 57
      * @var array
58 58
      */
59
-    protected $aJs = [];
59
+protected $aJs = [];
60 60
 
61
-    /**
61
+/**
62 62
      * @var array
63 63
      */
64
-    protected $aCodeJs = [];
64
+protected $aCodeJs = [];
65 65
 
66
-    /**
66
+/**
67 67
      * @var array
68 68
      */
69
-    protected $aCodeJsBefore = [];
69
+protected $aCodeJsBefore = [];
70 70
 
71
-    /**
71
+/**
72 72
      * @var array
73 73
      */
74
-    protected $aCodeJsAfter = [];
74
+protected $aCodeJsAfter = [];
75 75
 
76
-    /**
76
+/**
77 77
      * @var array
78 78
      */
79
-    protected $aCodeJsFiles = [];
79
+protected $aCodeJsFiles = [];
80 80
 
81
-    /**
81
+/**
82 82
      * @var bool
83 83
      */
84
-    protected $bGenerated = false;
84
+protected $bGenerated = false;
85 85
 
86
-    /**
86
+/**
87 87
      * The constructor
88 88
      *
89 89
      * @param string $sVersion
90 90
      * @param Container $di
91 91
      * @param TemplateEngine $xTemplateEngine
92 92
      */
93
-    public function __construct(private string $sVersion, private Container $di,
94
-        private TemplateEngine $xTemplateEngine)
95
-    {
96
-        // The Jaxon library config is on top.
97
-        $this->addCodeGenerator(ConfigScriptGenerator::class, 0);
98
-        // The ready script comes after.
99
-        $this->addCodeGenerator(ReadyScriptGenerator::class, 200);
100
-    }
101
-
102
-    /**
93
+public function __construct(private string $sVersion, private Container $di,
94
+private TemplateEngine $xTemplateEngine)
95
+{
96
+// The Jaxon library config is on top.
97
+$this->addCodeGenerator(ConfigScriptGenerator::class, 0);
98
+// The ready script comes after.
99
+$this->addCodeGenerator(ReadyScriptGenerator::class, 200);
100
+}
101
+
102
+/**
103 103
      * Add a code generator to the list
104 104
      *
105 105
      * @param string $sClassName    The code generator class
@@ -107,39 +107,39 @@  discard block
 block discarded – undo
107 107
      *
108 108
      * @return void
109 109
      */
110
-    public function addCodeGenerator(string $sClassName, int $nPriority): void
111
-    {
112
-        while(isset($this->aCodeGenerators[$nPriority]))
113
-        {
114
-            $nPriority++;
115
-        }
116
-        $this->aCodeGenerators[$nPriority] = $sClassName;
117
-    }
118
-
119
-    /**
110
+public function addCodeGenerator(string $sClassName, int $nPriority): void
111
+{
112
+while(isset($this->aCodeGenerators[$nPriority]))
113
+{
114
+$nPriority++;
115
+}
116
+$this->aCodeGenerators[$nPriority] = $sClassName;
117
+}
118
+
119
+/**
120 120
      * @param string $sClassName
121 121
      *
122 122
      * @return CodeGeneratorInterface
123 123
      */
124
-    private function getCodeGenerator(string $sClassName): CodeGeneratorInterface
125
-    {
126
-        return $this->di->g($sClassName);
127
-    }
124
+private function getCodeGenerator(string $sClassName): CodeGeneratorInterface
125
+{
126
+return $this->di->g($sClassName);
127
+}
128 128
 
129
-    /**
129
+/**
130 130
      * Generate a hash for all the javascript code generated by the library
131 131
      *
132 132
      * @return string
133 133
      */
134
-    public function getHash(): string
135
-    {
136
-        $aHashes = array_map(fn($sClassName) =>
137
-            $this->getCodeGenerator($sClassName)->getHash(), $this->aCodeGenerators);
138
-        $aHashes[] = $this->sVersion;
139
-        return md5(implode('', $aHashes));
140
-    }
141
-
142
-    /**
134
+public function getHash(): string
135
+{
136
+$aHashes = array_map(fn($sClassName) =>
137
+$this->getCodeGenerator($sClassName)->getHash(), $this->aCodeGenerators);
138
+$aHashes[] = $this->sVersion;
139
+return md5(implode('', $aHashes));
140
+}
141
+
142
+/**
143 143
      * Render a template in the 'plugins' subdir
144 144
      *
145 145
      * @param string $sTemplate    The template filename
@@ -147,185 +147,185 @@  discard block
 block discarded – undo
147 147
      *
148 148
      * @return string
149 149
      */
150
-    private function render(string $sTemplate, array $aVars = []): string
151
-    {
152
-        $aVars['sJsOptions'] = $this->sJsOptions;
153
-        return $this->xTemplateEngine->render("jaxon::plugins/$sTemplate", $aVars);
154
-    }
150
+private function render(string $sTemplate, array $aVars = []): string
151
+{
152
+$aVars['sJsOptions'] = $this->sJsOptions;
153
+return $this->xTemplateEngine->render("jaxon::plugins/$sTemplate", $aVars);
154
+}
155 155
 
156
-    /**
156
+/**
157 157
      * Generate the Jaxon CSS and js codes for a given plugin
158 158
      *
159 159
      * @param CodeGeneratorInterface $xGenerator
160 160
      *
161 161
      * @return void
162 162
      */
163
-    private function generatePluginCodes(CodeGeneratorInterface $xGenerator): void
164
-    {
165
-        if(!is_subclass_of($xGenerator, AbstractPlugin::class) ||
166
-            $this->xAssetManager->shallIncludeAssets($xGenerator))
167
-        {
168
-            // HTML tags for CSS
169
-            if(($sCss = trim($xGenerator->getCss(), " \n")) !== '')
170
-            {
171
-                $this->aCss[] = $sCss;
172
-            }
173
-            // HTML tags for js
174
-            if(($sJs = trim($xGenerator->getJs(), " \n")) !== '')
175
-            {
176
-                $this->aJs[] = $sJs;
177
-            }
178
-        }
179
-
180
-        // Additional js codes
181
-        if(($xJsCode = $xGenerator->getJsCode()) !== null)
182
-        {
183
-            if(($sJs = trim($xJsCode->sJs, " \n")) !== '')
184
-            {
185
-                $this->aCodeJs[] = $sJs;
186
-            }
187
-            if(($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '')
188
-            {
189
-                $this->aCodeJsBefore[] = $sJsBefore;
190
-            }
191
-            if(($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '')
192
-            {
193
-                $this->aCodeJsAfter[] = $sJsAfter;
194
-            }
195
-            $this->aCodeJsFiles = array_merge($this->aCodeJsFiles, $xJsCode->aFiles);
196
-        }
197
-    }
198
-
199
-    /**
163
+private function generatePluginCodes(CodeGeneratorInterface $xGenerator): void
164
+{
165
+if(!is_subclass_of($xGenerator, AbstractPlugin::class) ||
166
+$this->xAssetManager->shallIncludeAssets($xGenerator))
167
+{
168
+// HTML tags for CSS
169
+if(($sCss = trim($xGenerator->getCss(), " \n")) !== '')
170
+{
171
+    $this->aCss[] = $sCss;
172
+}
173
+// HTML tags for js
174
+if(($sJs = trim($xGenerator->getJs(), " \n")) !== '')
175
+{
176
+    $this->aJs[] = $sJs;
177
+}
178
+}
179
+
180
+// Additional js codes
181
+if(($xJsCode = $xGenerator->getJsCode()) !== null)
182
+{
183
+if(($sJs = trim($xJsCode->sJs, " \n")) !== '')
184
+{
185
+    $this->aCodeJs[] = $sJs;
186
+}
187
+if(($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '')
188
+{
189
+    $this->aCodeJsBefore[] = $sJsBefore;
190
+}
191
+if(($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '')
192
+{
193
+    $this->aCodeJsAfter[] = $sJsAfter;
194
+}
195
+$this->aCodeJsFiles = array_merge($this->aCodeJsFiles, $xJsCode->aFiles);
196
+}
197
+}
198
+
199
+/**
200 200
      * Generate the Jaxon CSS ans js codes
201 201
      *
202 202
      * @return void
203 203
      * @throws UriException
204 204
      */
205
-    private function generateCodes(): void
206
-    {
207
-        if($this->bGenerated)
208
-        {
209
-            return;
210
-        }
211
-
212
-        // We need the library to have been bootstrapped.
213
-        $this->di->getBootstrap()->onBoot();
214
-
215
-        // Sort the code generators by ascending priority
216
-        ksort($this->aCodeGenerators);
217
-
218
-        // Cannot be injected because of dependency loop.
219
-        $this->xAssetManager = $this->di->getAssetManager();
220
-
221
-        $this->sJsOptions = $this->xAssetManager->getJsOptions();
222
-        foreach($this->aCodeGenerators as $sClassName)
223
-        {
224
-            $this->generatePluginCodes($this->getCodeGenerator($sClassName));
225
-        }
226
-
227
-        // Load the Jaxon lib js files, after the other libs js files.
228
-        $this->aJs[] = trim($this->render('includes.js', [
229
-            'aUrls' => $this->xAssetManager->getJsLibFiles(),
230
-        ]));
231
-
232
-        // The codes are already generated.
233
-        $this->bGenerated = true;
234
-    }
235
-
236
-    /**
205
+private function generateCodes(): void
206
+{
207
+if($this->bGenerated)
208
+{
209
+return;
210
+}
211
+
212
+// We need the library to have been bootstrapped.
213
+$this->di->getBootstrap()->onBoot();
214
+
215
+// Sort the code generators by ascending priority
216
+ksort($this->aCodeGenerators);
217
+
218
+// Cannot be injected because of dependency loop.
219
+$this->xAssetManager = $this->di->getAssetManager();
220
+
221
+$this->sJsOptions = $this->xAssetManager->getJsOptions();
222
+foreach($this->aCodeGenerators as $sClassName)
223
+{
224
+$this->generatePluginCodes($this->getCodeGenerator($sClassName));
225
+}
226
+
227
+// Load the Jaxon lib js files, after the other libs js files.
228
+$this->aJs[] = trim($this->render('includes.js', [
229
+'aUrls' => $this->xAssetManager->getJsLibFiles(),
230
+]));
231
+
232
+// The codes are already generated.
233
+$this->bGenerated = true;
234
+}
235
+
236
+/**
237 237
      * Get the HTML tags to include Jaxon CSS code and files into the page
238 238
      *
239 239
      * @return string
240 240
      * @throws UriException
241 241
      */
242
-    public function getCss(): string
243
-    {
244
-        $this->generateCodes();
245
-        return implode("\n\n", $this->aCss);
246
-    }
242
+public function getCss(): string
243
+{
244
+$this->generateCodes();
245
+return implode("\n\n", $this->aCss);
246
+}
247 247
 
248
-    /**
248
+/**
249 249
      * Get the HTML tags to include Jaxon javascript files into the page
250 250
      *
251 251
      * @return string
252 252
      * @throws UriException
253 253
      */
254
-    public function getJs(): string
255
-    {
256
-        $this->generateCodes();
257
-        return implode("\n\n", $this->aJs);
258
-    }
254
+public function getJs(): string
255
+{
256
+$this->generateCodes();
257
+return implode("\n\n", $this->aJs);
258
+}
259 259
 
260
-    /**
260
+/**
261 261
      * Get the Javascript code
262 262
      *
263 263
      * @return string
264 264
      */
265
-    public function getJsScript(): string
266
-    {
267
-        $aJsScripts = [];
268
-        foreach($this->aCodeGenerators as $sClassName)
269
-        {
270
-            $xGenerator = $this->getCodeGenerator($sClassName);
271
-            // Javascript code
272
-            if(($sJsScript = trim($xGenerator->getScript(), " \n")) !== '')
273
-            {
274
-                $aJsScripts[] = $sJsScript;
275
-            }
276
-        }
277
-        return implode("\n\n", $aJsScripts);
278
-    }
279
-
280
-    /**
265
+public function getJsScript(): string
266
+{
267
+$aJsScripts = [];
268
+foreach($this->aCodeGenerators as $sClassName)
269
+{
270
+$xGenerator = $this->getCodeGenerator($sClassName);
271
+// Javascript code
272
+if(($sJsScript = trim($xGenerator->getScript(), " \n")) !== '')
273
+{
274
+    $aJsScripts[] = $sJsScript;
275
+}
276
+}
277
+return implode("\n\n", $aJsScripts);
278
+}
279
+
280
+/**
281 281
      * @param bool $bIncludeJs Also get the JS files
282 282
      * @param bool $bIncludeCss Also get the CSS files
283 283
      *
284 284
      * @return array<string>
285 285
      */
286
-    private function renderCodes(bool $bIncludeJs, bool $bIncludeCss): array
287
-    {
288
-        $aCodes = [];
289
-        if($bIncludeCss)
290
-        {
291
-            $aCodes[] = $this->getCss();
292
-        }
293
-        if($bIncludeJs)
294
-        {
295
-            $aCodes[] = $this->getJs();
296
-        }
297
-
298
-        $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' :
299
-            $this->xAssetManager->createJsFiles($this);
300
-        // Wrap the js code into the corresponding HTML tag.
301
-        $aCodes[] = $sUrl !== '' ?
302
-            $this->render('include.js', ['sUrl' => $sUrl]) :
303
-            $this->render('wrapper.js', ['sScript' => $this->getJsScript()]);
304
-
305
-        // Wrap the js codes into HTML tags.
306
-        if(count($this->aCodeJsBefore) > 0)
307
-        {
308
-            $sScript = implode("\n\n", $this->aCodeJsBefore);
309
-            $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
310
-        }
311
-        if(count($this->aCodeJs) > 0)
312
-        {
313
-            $sScript = implode("\n\n", $this->aCodeJs);
314
-            $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
315
-        }
316
-        if(count($this->aCodeJsFiles) > 0)
317
-        {
318
-            $aCodes[] = $this->render('includes.js', ['aUrls' => $this->aCodeJsFiles]);
319
-        }
320
-        if(count($this->aCodeJsAfter) > 0)
321
-        {
322
-            $sScript = implode("\n\n", $this->aCodeJsAfter);
323
-            $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
324
-        }
325
-        return $aCodes;
326
-    }
327
-
328
-    /**
286
+private function renderCodes(bool $bIncludeJs, bool $bIncludeCss): array
287
+{
288
+$aCodes = [];
289
+if($bIncludeCss)
290
+{
291
+$aCodes[] = $this->getCss();
292
+}
293
+if($bIncludeJs)
294
+{
295
+$aCodes[] = $this->getJs();
296
+}
297
+
298
+$sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' :
299
+$this->xAssetManager->createJsFiles($this);
300
+// Wrap the js code into the corresponding HTML tag.
301
+$aCodes[] = $sUrl !== '' ?
302
+$this->render('include.js', ['sUrl' => $sUrl]) :
303
+$this->render('wrapper.js', ['sScript' => $this->getJsScript()]);
304
+
305
+// Wrap the js codes into HTML tags.
306
+if(count($this->aCodeJsBefore) > 0)
307
+{
308
+$sScript = implode("\n\n", $this->aCodeJsBefore);
309
+$aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
310
+}
311
+if(count($this->aCodeJs) > 0)
312
+{
313
+$sScript = implode("\n\n", $this->aCodeJs);
314
+$aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
315
+}
316
+if(count($this->aCodeJsFiles) > 0)
317
+{
318
+$aCodes[] = $this->render('includes.js', ['aUrls' => $this->aCodeJsFiles]);
319
+}
320
+if(count($this->aCodeJsAfter) > 0)
321
+{
322
+$sScript = implode("\n\n", $this->aCodeJsAfter);
323
+$aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
324
+}
325
+return $aCodes;
326
+}
327
+
328
+/**
329 329
      * Get the javascript code to be sent to the browser
330 330
      *
331 331
      * @param bool $bIncludeJs Also get the JS files
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
      * @return string
335 335
      * @throws UriException
336 336
      */
337
-    public function getScript(bool $bIncludeJs, bool $bIncludeCss): string
338
-    {
339
-        $this->generateCodes();
340
-        $aCodes = $this->renderCodes($bIncludeJs, $bIncludeCss);
341
-        return implode("\n\n", $aCodes);
342
-    }
337
+public function getScript(bool $bIncludeJs, bool $bIncludeCss): string
338
+{
339
+$this->generateCodes();
340
+$aCodes = $this->renderCodes($bIncludeJs, $bIncludeCss);
341
+return implode("\n\n", $aCodes);
342
+}
343 343
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -22 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function addCodeGenerator(string $sClassName, int $nPriority): void
111 111
     {
112
-        while(isset($this->aCodeGenerators[$nPriority]))
112
+        while (isset($this->aCodeGenerators[$nPriority]))
113 113
         {
114 114
             $nPriority++;
115 115
         }
@@ -162,33 +162,33 @@  discard block
 block discarded – undo
162 162
      */
163 163
     private function generatePluginCodes(CodeGeneratorInterface $xGenerator): void
164 164
     {
165
-        if(!is_subclass_of($xGenerator, AbstractPlugin::class) ||
165
+        if (!is_subclass_of($xGenerator, AbstractPlugin::class) ||
166 166
             $this->xAssetManager->shallIncludeAssets($xGenerator))
167 167
         {
168 168
             // HTML tags for CSS
169
-            if(($sCss = trim($xGenerator->getCss(), " \n")) !== '')
169
+            if (($sCss = trim($xGenerator->getCss(), " \n")) !== '')
170 170
             {
171 171
                 $this->aCss[] = $sCss;
172 172
             }
173 173
             // HTML tags for js
174
-            if(($sJs = trim($xGenerator->getJs(), " \n")) !== '')
174
+            if (($sJs = trim($xGenerator->getJs(), " \n")) !== '')
175 175
             {
176 176
                 $this->aJs[] = $sJs;
177 177
             }
178 178
         }
179 179
 
180 180
         // Additional js codes
181
-        if(($xJsCode = $xGenerator->getJsCode()) !== null)
181
+        if (($xJsCode = $xGenerator->getJsCode()) !== null)
182 182
         {
183
-            if(($sJs = trim($xJsCode->sJs, " \n")) !== '')
183
+            if (($sJs = trim($xJsCode->sJs, " \n")) !== '')
184 184
             {
185 185
                 $this->aCodeJs[] = $sJs;
186 186
             }
187
-            if(($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '')
187
+            if (($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '')
188 188
             {
189 189
                 $this->aCodeJsBefore[] = $sJsBefore;
190 190
             }
191
-            if(($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '')
191
+            if (($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '')
192 192
             {
193 193
                 $this->aCodeJsAfter[] = $sJsAfter;
194 194
             }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     private function generateCodes(): void
206 206
     {
207
-        if($this->bGenerated)
207
+        if ($this->bGenerated)
208 208
         {
209 209
             return;
210 210
         }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $this->xAssetManager = $this->di->getAssetManager();
220 220
 
221 221
         $this->sJsOptions = $this->xAssetManager->getJsOptions();
222
-        foreach($this->aCodeGenerators as $sClassName)
222
+        foreach ($this->aCodeGenerators as $sClassName)
223 223
         {
224 224
             $this->generatePluginCodes($this->getCodeGenerator($sClassName));
225 225
         }
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
     public function getJsScript(): string
266 266
     {
267 267
         $aJsScripts = [];
268
-        foreach($this->aCodeGenerators as $sClassName)
268
+        foreach ($this->aCodeGenerators as $sClassName)
269 269
         {
270 270
             $xGenerator = $this->getCodeGenerator($sClassName);
271 271
             // Javascript code
272
-            if(($sJsScript = trim($xGenerator->getScript(), " \n")) !== '')
272
+            if (($sJsScript = trim($xGenerator->getScript(), " \n")) !== '')
273 273
             {
274 274
                 $aJsScripts[] = $sJsScript;
275 275
             }
@@ -286,38 +286,36 @@  discard block
 block discarded – undo
286 286
     private function renderCodes(bool $bIncludeJs, bool $bIncludeCss): array
287 287
     {
288 288
         $aCodes = [];
289
-        if($bIncludeCss)
289
+        if ($bIncludeCss)
290 290
         {
291 291
             $aCodes[] = $this->getCss();
292 292
         }
293
-        if($bIncludeJs)
293
+        if ($bIncludeJs)
294 294
         {
295 295
             $aCodes[] = $this->getJs();
296 296
         }
297 297
 
298
-        $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' :
299
-            $this->xAssetManager->createJsFiles($this);
298
+        $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' : $this->xAssetManager->createJsFiles($this);
300 299
         // Wrap the js code into the corresponding HTML tag.
301 300
         $aCodes[] = $sUrl !== '' ?
302
-            $this->render('include.js', ['sUrl' => $sUrl]) :
303
-            $this->render('wrapper.js', ['sScript' => $this->getJsScript()]);
301
+            $this->render('include.js', ['sUrl' => $sUrl]) : $this->render('wrapper.js', ['sScript' => $this->getJsScript()]);
304 302
 
305 303
         // Wrap the js codes into HTML tags.
306
-        if(count($this->aCodeJsBefore) > 0)
304
+        if (count($this->aCodeJsBefore) > 0)
307 305
         {
308 306
             $sScript = implode("\n\n", $this->aCodeJsBefore);
309 307
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
310 308
         }
311
-        if(count($this->aCodeJs) > 0)
309
+        if (count($this->aCodeJs) > 0)
312 310
         {
313 311
             $sScript = implode("\n\n", $this->aCodeJs);
314 312
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
315 313
         }
316
-        if(count($this->aCodeJsFiles) > 0)
314
+        if (count($this->aCodeJsFiles) > 0)
317 315
         {
318 316
             $aCodes[] = $this->render('includes.js', ['aUrls' => $this->aCodeJsFiles]);
319 317
         }
320
-        if(count($this->aCodeJsAfter) > 0)
318
+        if (count($this->aCodeJsAfter) > 0)
321 319
         {
322 320
             $sScript = implode("\n\n", $this->aCodeJsAfter);
323 321
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
Please login to merge, or discard this patch.
jaxon-core/templates/callables/objects.js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
   rc: (name, method, parameters, options = {}) => jaxon.request({ type: 'class', name, method }, { parameters, ...options}),
3 3
   rf: (name, parameters, options = {}) => jaxon.request({ type: 'func', name }, { parameters, ...options}),
4 4
 <?php
5
-foreach($this->aCallableNames as $nIndex => $sName):
5
+foreach ($this->aCallableNames as $nIndex => $sName):
6 6
   echo "  c$nIndex: '$sName',\n";
7 7
 endforeach
8 8
 ?>
Please login to merge, or discard this patch.
jaxon-core/templates/plugins/config.js.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
 jaxon.config.defaultMethod = '<?php echo $this->sDefaultMethod ?>';
7 7
 jaxon.config.responseType = '<?php echo $this->sResponseType ?>';
8 8
 
9
-<?php if($this->nResponseQueueSize > 0): ?>
9
+<?php if ($this->nResponseQueueSize > 0): ?>
10 10
 jaxon.config.responseQueueSize = <?php echo $this->nResponseQueueSize ?>;
11 11
 <?php endif ?>
12 12
 
13
-<?php if($this->bLoggingEnabled): ?>
13
+<?php if ($this->bLoggingEnabled): ?>
14 14
 jaxon.debug.logger = '<?php echo Jaxon\rq(Jaxon\App\Component\Logger::class)->_class() ?>';
15 15
 <?php endif ?>
16 16
 
17
-<?php if($this->bDebug): ?>
17
+<?php if ($this->bDebug): ?>
18 18
 jaxon.debug.active = true;
19
-<?php if($this->sDebugOutputID): ?>
19
+<?php if ($this->sDebugOutputID): ?>
20 20
 jaxon.debug.outputID = '<?php echo $this->sDebugOutputID ?>';
21 21
 <?php endif ?>
22
-<?php if($this->bVerboseDebug): ?>
22
+<?php if ($this->bVerboseDebug): ?>
23 23
 jaxon.debug.verbose.active = true;
24 24
 <?php endif ?>
25 25
 <?php endif ?>
26 26
 
27
-<?php if($this->sCsrfMetaName): ?>
27
+<?php if ($this->sCsrfMetaName): ?>
28 28
 jaxon.setCsrf('<?php echo $this->sCsrfMetaName ?>');
29 29
 <?php endif ?>
Please login to merge, or discard this patch.
jaxon-upload/tests/TestUpload/UploadHandlerTest.php 1 patch
Switch Indentation   +551 added lines, -551 removed lines patch added patch discarded remove patch
@@ -21,605 +21,605 @@
 block discarded – undo
21 21
 
22 22
 class UploadHandlerTest extends TestCase
23 23
 {
24
-    /**
24
+/**
25 25
      * @var string
26 26
      */
27
-    protected $sNameWhite;
27
+protected $sNameWhite;
28 28
 
29
-    /**
29
+/**
30 30
      * @var string
31 31
      */
32
-    protected $sPathWhite;
32
+protected $sPathWhite;
33 33
 
34
-    /**
34
+/**
35 35
      * @var int
36 36
      */
37
-    protected $sSizeWhite;
37
+protected $sSizeWhite;
38 38
 
39
-    /**
39
+/**
40 40
      * @var string
41 41
      */
42
-    protected $sNameBlue;
42
+protected $sNameBlue;
43 43
 
44
-    /**
44
+/**
45 45
      * @var string
46 46
      */
47
-    protected $sPathBlue;
47
+protected $sPathBlue;
48 48
 
49
-    /**
49
+/**
50 50
      * @var int
51 51
      */
52
-    protected $sSizeBlue;
52
+protected $sSizeBlue;
53 53
 
54
-    /**
54
+/**
55 55
      * @throws SetupException
56 56
      */
57
-    public function setUp(): void
58
-    {
59
-        jaxon()->di()->getPluginManager()->registerPlugins();
60
-        _register();
61
-        jaxon()->setOption('core.upload.enabled', true);
62
-        jaxon()->setOption('core.response.send', false);
63
-
64
-        $tmpDir = __DIR__ . '/../upload/tmp';
65
-        @mkdir($tmpDir);
66
-
67
-        $sSrcWhite = __DIR__ . '/../upload/src/white.png';
68
-        $this->sNameWhite = 'white.png';
69
-        $this->sPathWhite = "$tmpDir/{$this->sNameWhite}";
70
-        $this->sSizeWhite = filesize($sSrcWhite);
71
-        // Copy the file to the temp dir.
72
-        @copy($sSrcWhite, $this->sPathWhite);
73
-
74
-        $sSrcBlue = __DIR__ . '/../upload/src/blue.png';
75
-        $this->sNameBlue = 'blue.png';
76
-        $this->sPathBlue = "$tmpDir/{$this->sNameBlue}";
77
-        $this->sSizeBlue = filesize($sSrcBlue);
78
-        // Copy the file to the temp dir.
79
-        @copy($sSrcBlue, $this->sPathBlue);
80
-
81
-        jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
82
-        jaxon()->di()->getBootstrap()->onBoot();
83
-    }
84
-
85
-    /**
57
+public function setUp(): void
58
+{
59
+jaxon()->di()->getPluginManager()->registerPlugins();
60
+_register();
61
+jaxon()->setOption('core.upload.enabled', true);
62
+jaxon()->setOption('core.response.send', false);
63
+
64
+$tmpDir = __DIR__ . '/../upload/tmp';
65
+@mkdir($tmpDir);
66
+
67
+$sSrcWhite = __DIR__ . '/../upload/src/white.png';
68
+$this->sNameWhite = 'white.png';
69
+$this->sPathWhite = "$tmpDir/{$this->sNameWhite}";
70
+$this->sSizeWhite = filesize($sSrcWhite);
71
+// Copy the file to the temp dir.
72
+@copy($sSrcWhite, $this->sPathWhite);
73
+
74
+$sSrcBlue = __DIR__ . '/../upload/src/blue.png';
75
+$this->sNameBlue = 'blue.png';
76
+$this->sPathBlue = "$tmpDir/{$this->sNameBlue}";
77
+$this->sSizeBlue = filesize($sSrcBlue);
78
+// Copy the file to the temp dir.
79
+@copy($sSrcBlue, $this->sPathBlue);
80
+
81
+jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
82
+jaxon()->di()->getBootstrap()->onBoot();
83
+}
84
+
85
+/**
86 86
      * @throws SetupException
87 87
      */
88
-    public function tearDown(): void
89
-    {
90
-        jaxon()->reset();
91
-        parent::tearDown();
92
-    }
88
+public function tearDown(): void
89
+{
90
+jaxon()->reset();
91
+parent::tearDown();
92
+}
93 93
 
94
-    /**
94
+/**
95 95
      * @throws RequestException
96 96
      */
97
-    public function testAjaxUpload()
98
-    {
99
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
100
-        // Send a request to the registered class
101
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
102
-            return $c->g(ServerRequestCreator::class)
103
-                ->fromGlobals()
104
-                ->withParsedBody([
105
-                    'jxncall' => json_encode([
106
-                        'type' => 'class',
107
-                        'name' => 'SampleUpload',
108
-                        'method' => 'myMethod',
109
-                        'args' => [],
110
-                    ]),
111
-                ])
112
-                ->withUploadedFiles([
113
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
114
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
115
-                ])
116
-                ->withMethod('POST');
117
-        });
118
-
119
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
120
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
121
-        jaxon()->processRequest();
122
-
123
-        // Uploaded files
124
-        $aFiles = jaxon()->upload()->files();
125
-        $this->assertCount(1, $aFiles);
126
-        $this->assertCount(1, $aFiles['image']);
127
-        $xFile = $aFiles['image'][0];
128
-        $this->assertEquals('white', $xFile->name());
129
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
130
-        $this->assertEquals('png', $xFile->type());
131
-        $this->assertEquals('png', $xFile->extension());
132
-    }
133
-
134
-    /**
97
+public function testAjaxUpload()
98
+{
99
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
100
+// Send a request to the registered class
101
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
102
+return $c->g(ServerRequestCreator::class)
103
+    ->fromGlobals()
104
+    ->withParsedBody([
105
+        'jxncall' => json_encode([
106
+            'type' => 'class',
107
+            'name' => 'SampleUpload',
108
+            'method' => 'myMethod',
109
+            'args' => [],
110
+        ]),
111
+    ])
112
+    ->withUploadedFiles([
113
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
114
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
115
+    ])
116
+    ->withMethod('POST');
117
+});
118
+
119
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
120
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
121
+jaxon()->processRequest();
122
+
123
+// Uploaded files
124
+$aFiles = jaxon()->upload()->files();
125
+$this->assertCount(1, $aFiles);
126
+$this->assertCount(1, $aFiles['image']);
127
+$xFile = $aFiles['image'][0];
128
+$this->assertEquals('white', $xFile->name());
129
+$this->assertEquals($this->sNameWhite, $xFile->filename());
130
+$this->assertEquals('png', $xFile->type());
131
+$this->assertEquals('png', $xFile->extension());
132
+}
133
+
134
+/**
135 135
      * @throws RequestException
136 136
      */
137
-    public function testAjaxUploadMultipleFiles()
138
-    {
139
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
140
-        // Send a request to the registered class
141
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
142
-            return $c->g(ServerRequestCreator::class)
143
-                ->fromGlobals()
144
-                ->withParsedBody([
145
-                    'jxncall' => json_encode([
146
-                        'type' => 'class',
147
-                        'name' => 'SampleUpload',
148
-                        'method' => 'myMethod',
149
-                        'args' => [],
150
-                    ]),
151
-                ])
152
-                ->withUploadedFiles([
153
-                    'image' => [
154
-                        new UploadedFile($this->sPathWhite, $this->sSizeWhite,
155
-                            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
156
-                        new UploadedFile($this->sPathBlue, $this->sSizeBlue,
157
-                            UPLOAD_ERR_OK, $this->sNameBlue, 'png'),
158
-                    ],
159
-                ])
160
-                ->withMethod('POST');
161
-        });
162
-
163
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
164
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
165
-        jaxon()->processRequest();
166
-
167
-        // Uploaded files
168
-        $aFiles = jaxon()->upload()->files();
169
-        $this->assertCount(1, $aFiles);
170
-        $this->assertCount(2, $aFiles['image']);
171
-        $xFile = $aFiles['image'][0];
172
-        $this->assertEquals('white', $xFile->name());
173
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
174
-        $this->assertEquals('png', $xFile->type());
175
-        $this->assertEquals('png', $xFile->extension());
176
-        $xFile = $aFiles['image'][1];
177
-        $this->assertEquals('blue', $xFile->name());
178
-        $this->assertEquals($this->sNameBlue, $xFile->filename());
179
-        $this->assertEquals('png', $xFile->type());
180
-        $this->assertEquals('png', $xFile->extension());
181
-    }
182
-
183
-    /**
137
+public function testAjaxUploadMultipleFiles()
138
+{
139
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
140
+// Send a request to the registered class
141
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
142
+return $c->g(ServerRequestCreator::class)
143
+    ->fromGlobals()
144
+    ->withParsedBody([
145
+        'jxncall' => json_encode([
146
+            'type' => 'class',
147
+            'name' => 'SampleUpload',
148
+            'method' => 'myMethod',
149
+            'args' => [],
150
+        ]),
151
+    ])
152
+    ->withUploadedFiles([
153
+        'image' => [
154
+            new UploadedFile($this->sPathWhite, $this->sSizeWhite,
155
+                UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
156
+            new UploadedFile($this->sPathBlue, $this->sSizeBlue,
157
+                UPLOAD_ERR_OK, $this->sNameBlue, 'png'),
158
+        ],
159
+    ])
160
+    ->withMethod('POST');
161
+});
162
+
163
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
164
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
165
+jaxon()->processRequest();
166
+
167
+// Uploaded files
168
+$aFiles = jaxon()->upload()->files();
169
+$this->assertCount(1, $aFiles);
170
+$this->assertCount(2, $aFiles['image']);
171
+$xFile = $aFiles['image'][0];
172
+$this->assertEquals('white', $xFile->name());
173
+$this->assertEquals($this->sNameWhite, $xFile->filename());
174
+$this->assertEquals('png', $xFile->type());
175
+$this->assertEquals('png', $xFile->extension());
176
+$xFile = $aFiles['image'][1];
177
+$this->assertEquals('blue', $xFile->name());
178
+$this->assertEquals($this->sNameBlue, $xFile->filename());
179
+$this->assertEquals('png', $xFile->type());
180
+$this->assertEquals('png', $xFile->extension());
181
+}
182
+
183
+/**
184 184
      * @throws RequestException
185 185
      */
186
-    public function testAjaxUploadMultipleNames()
187
-    {
188
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
189
-        // Send a request to the registered class
190
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
191
-            return $c->g(ServerRequestCreator::class)
192
-                ->fromGlobals()
193
-                ->withParsedBody([
194
-                    'jxncall' => json_encode([
195
-                        'type' => 'class',
196
-                        'name' => 'SampleUpload',
197
-                        'method' => 'myMethod',
198
-                        'args' => [],
199
-                    ]),
200
-                ])
201
-                ->withUploadedFiles([
202
-                    'white' => [
203
-                        new UploadedFile($this->sPathWhite, $this->sSizeWhite,
204
-                            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
205
-                    ],
206
-                    'blue' => [
207
-                        new UploadedFile($this->sPathBlue, $this->sSizeBlue,
208
-                            UPLOAD_ERR_OK, $this->sNameBlue, 'png'),
209
-                    ],
210
-                ])
211
-                ->withMethod('POST');
212
-        });
213
-
214
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
215
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
216
-        jaxon()->processRequest();
217
-
218
-        // Uploaded files
219
-        $aFiles = jaxon()->upload()->files();
220
-        $this->assertCount(2, $aFiles);
221
-        $this->assertCount(1, $aFiles['white']);
222
-        $this->assertCount(1, $aFiles['blue']);
223
-        $xFile = $aFiles['white'][0];
224
-        $this->assertEquals('white', $xFile->name());
225
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
226
-        $this->assertEquals('png', $xFile->type());
227
-        $this->assertEquals('png', $xFile->extension());
228
-        $xFile = $aFiles['blue'][0];
229
-        $this->assertEquals('blue', $xFile->name());
230
-        $this->assertEquals($this->sNameBlue, $xFile->filename());
231
-        $this->assertEquals('png', $xFile->type());
232
-        $this->assertEquals('png', $xFile->extension());
233
-    }
234
-
235
-    /**
186
+public function testAjaxUploadMultipleNames()
187
+{
188
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
189
+// Send a request to the registered class
190
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
191
+return $c->g(ServerRequestCreator::class)
192
+    ->fromGlobals()
193
+    ->withParsedBody([
194
+        'jxncall' => json_encode([
195
+            'type' => 'class',
196
+            'name' => 'SampleUpload',
197
+            'method' => 'myMethod',
198
+            'args' => [],
199
+        ]),
200
+    ])
201
+    ->withUploadedFiles([
202
+        'white' => [
203
+            new UploadedFile($this->sPathWhite, $this->sSizeWhite,
204
+                UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
205
+        ],
206
+        'blue' => [
207
+            new UploadedFile($this->sPathBlue, $this->sSizeBlue,
208
+                UPLOAD_ERR_OK, $this->sNameBlue, 'png'),
209
+        ],
210
+    ])
211
+    ->withMethod('POST');
212
+});
213
+
214
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
215
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
216
+jaxon()->processRequest();
217
+
218
+// Uploaded files
219
+$aFiles = jaxon()->upload()->files();
220
+$this->assertCount(2, $aFiles);
221
+$this->assertCount(1, $aFiles['white']);
222
+$this->assertCount(1, $aFiles['blue']);
223
+$xFile = $aFiles['white'][0];
224
+$this->assertEquals('white', $xFile->name());
225
+$this->assertEquals($this->sNameWhite, $xFile->filename());
226
+$this->assertEquals('png', $xFile->type());
227
+$this->assertEquals('png', $xFile->extension());
228
+$xFile = $aFiles['blue'][0];
229
+$this->assertEquals('blue', $xFile->name());
230
+$this->assertEquals($this->sNameBlue, $xFile->filename());
231
+$this->assertEquals('png', $xFile->type());
232
+$this->assertEquals('png', $xFile->extension());
233
+}
234
+
235
+/**
236 236
      * @throws RequestException
237 237
      */
238
-    public function testAjaxUploadNameSanitizer()
239
-    {
240
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
241
-        jaxon()->upload()->sanitizer(function($sFilename, $sVarName) {
242
-            return $sVarName === 'image' ? 'img_' . $sFilename : $sFilename;
243
-        });
244
-        // Send a request to the registered class
245
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
246
-            return $c->g(ServerRequestCreator::class)
247
-                ->fromGlobals()
248
-                ->withParsedBody([
249
-                    'jxncall' => json_encode([
250
-                        'type' => 'class',
251
-                        'name' => 'SampleUpload',
252
-                        'method' => 'myMethod',
253
-                        'args' => [],
254
-                    ]),
255
-                ])
256
-                ->withUploadedFiles([
257
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
258
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
259
-                ])
260
-                ->withMethod('POST');
261
-        });
262
-
263
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
264
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
265
-        jaxon()->processRequest();
266
-
267
-        // Uploaded files
268
-        $aFiles = jaxon()->upload()->files();
269
-        $this->assertCount(1, $aFiles);
270
-        $this->assertCount(1, $aFiles['image']);
271
-        $xFile = $aFiles['image'][0];
272
-        $this->assertEquals('img_white', $xFile->name());
273
-        $this->assertEquals('png', $xFile->type());
274
-        $this->assertEquals('png', $xFile->extension());
275
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
276
-    }
277
-
278
-    /**
238
+public function testAjaxUploadNameSanitizer()
239
+{
240
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
241
+jaxon()->upload()->sanitizer(function($sFilename, $sVarName) {
242
+return $sVarName === 'image' ? 'img_' . $sFilename : $sFilename;
243
+});
244
+// Send a request to the registered class
245
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
246
+return $c->g(ServerRequestCreator::class)
247
+    ->fromGlobals()
248
+    ->withParsedBody([
249
+        'jxncall' => json_encode([
250
+            'type' => 'class',
251
+            'name' => 'SampleUpload',
252
+            'method' => 'myMethod',
253
+            'args' => [],
254
+        ]),
255
+    ])
256
+    ->withUploadedFiles([
257
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
258
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
259
+    ])
260
+    ->withMethod('POST');
261
+});
262
+
263
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
264
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
265
+jaxon()->processRequest();
266
+
267
+// Uploaded files
268
+$aFiles = jaxon()->upload()->files();
269
+$this->assertCount(1, $aFiles);
270
+$this->assertCount(1, $aFiles['image']);
271
+$xFile = $aFiles['image'][0];
272
+$this->assertEquals('img_white', $xFile->name());
273
+$this->assertEquals('png', $xFile->type());
274
+$this->assertEquals('png', $xFile->extension());
275
+$this->assertEquals($this->sNameWhite, $xFile->filename());
276
+}
277
+
278
+/**
279 279
      * @throws RequestException
280 280
      */
281
-    public function testUploadFileTypeValidationOk()
282
-    {
283
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
284
-        jaxon()->setOption('upload.default.types', ['png']);
285
-        // Send a request to the registered class
286
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
287
-            return $c->g(ServerRequestCreator::class)
288
-                ->fromGlobals()
289
-                ->withParsedBody([
290
-                    'jxncall' => json_encode([
291
-                        'type' => 'class',
292
-                        'name' => 'SampleUpload',
293
-                        'method' => 'myMethod',
294
-                        'args' => [],
295
-                    ]),
296
-                ])
297
-                ->withUploadedFiles([
298
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
299
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
300
-                ])
301
-                ->withMethod('POST');
302
-        });
303
-
304
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
305
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
306
-        jaxon()->processRequest();
307
-
308
-        // Return the file name for the next test
309
-        $aFiles = jaxon()->upload()->files();
310
-        $this->assertCount(1, $aFiles);
311
-        $this->assertCount(1, $aFiles['image']);
312
-        $xFile = $aFiles['image'][0];
313
-        $this->assertEquals('white', $xFile->name());
314
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
315
-    }
316
-
317
-    /**
281
+public function testUploadFileTypeValidationOk()
282
+{
283
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
284
+jaxon()->setOption('upload.default.types', ['png']);
285
+// Send a request to the registered class
286
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
287
+return $c->g(ServerRequestCreator::class)
288
+    ->fromGlobals()
289
+    ->withParsedBody([
290
+        'jxncall' => json_encode([
291
+            'type' => 'class',
292
+            'name' => 'SampleUpload',
293
+            'method' => 'myMethod',
294
+            'args' => [],
295
+        ]),
296
+    ])
297
+    ->withUploadedFiles([
298
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
299
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
300
+    ])
301
+    ->withMethod('POST');
302
+});
303
+
304
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
305
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
306
+jaxon()->processRequest();
307
+
308
+// Return the file name for the next test
309
+$aFiles = jaxon()->upload()->files();
310
+$this->assertCount(1, $aFiles);
311
+$this->assertCount(1, $aFiles['image']);
312
+$xFile = $aFiles['image'][0];
313
+$this->assertEquals('white', $xFile->name());
314
+$this->assertEquals($this->sNameWhite, $xFile->filename());
315
+}
316
+
317
+/**
318 318
      * @throws RequestException
319 319
      */
320
-    public function testUploadFileTypeValidationError()
321
-    {
322
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
323
-        jaxon()->setOption('upload.default.types', ['jpg']);
324
-        // Send a request to the registered class
325
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
326
-            return $c->g(ServerRequestCreator::class)
327
-                ->fromGlobals()
328
-                ->withParsedBody([
329
-                    'jxncall' => json_encode([
330
-                        'type' => 'class',
331
-                        'name' => 'SampleUpload',
332
-                        'method' => 'myMethod',
333
-                        'args' => [],
334
-                    ]),
335
-                ])
336
-                ->withUploadedFiles([
337
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
338
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
339
-                ])
340
-                ->withMethod('POST');
341
-        });
342
-
343
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
344
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
345
-        $this->expectException(RequestException::class);
346
-        jaxon()->processRequest();
347
-    }
348
-
349
-    /**
320
+public function testUploadFileTypeValidationError()
321
+{
322
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
323
+jaxon()->setOption('upload.default.types', ['jpg']);
324
+// Send a request to the registered class
325
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
326
+return $c->g(ServerRequestCreator::class)
327
+    ->fromGlobals()
328
+    ->withParsedBody([
329
+        'jxncall' => json_encode([
330
+            'type' => 'class',
331
+            'name' => 'SampleUpload',
332
+            'method' => 'myMethod',
333
+            'args' => [],
334
+        ]),
335
+    ])
336
+    ->withUploadedFiles([
337
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
338
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
339
+    ])
340
+    ->withMethod('POST');
341
+});
342
+
343
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
344
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
345
+$this->expectException(RequestException::class);
346
+jaxon()->processRequest();
347
+}
348
+
349
+/**
350 350
      * @throws RequestException
351 351
      */
352
-    public function testUploadFileExtensionValidationOk()
353
-    {
354
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
355
-        jaxon()->setOption('upload.default.extensions', ['png']);
356
-        // Send a request to the registered class
357
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
358
-            return $c->g(ServerRequestCreator::class)
359
-                ->fromGlobals()
360
-                ->withParsedBody([
361
-                    'jxncall' => json_encode([
362
-                        'type' => 'class',
363
-                        'name' => 'SampleUpload',
364
-                        'method' => 'myMethod',
365
-                        'args' => [],
366
-                    ]),
367
-                ])
368
-                ->withUploadedFiles([
369
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
370
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
371
-                ])
372
-                ->withMethod('POST');
373
-        });
374
-
375
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
376
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
377
-        jaxon()->processRequest();
378
-
379
-        // Return the file name for the next test
380
-        $aFiles = jaxon()->upload()->files();
381
-        $this->assertCount(1, $aFiles);
382
-        $this->assertCount(1, $aFiles['image']);
383
-        $xFile = $aFiles['image'][0];
384
-        $this->assertEquals('white', $xFile->name());
385
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
386
-    }
387
-
388
-    /**
352
+public function testUploadFileExtensionValidationOk()
353
+{
354
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
355
+jaxon()->setOption('upload.default.extensions', ['png']);
356
+// Send a request to the registered class
357
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
358
+return $c->g(ServerRequestCreator::class)
359
+    ->fromGlobals()
360
+    ->withParsedBody([
361
+        'jxncall' => json_encode([
362
+            'type' => 'class',
363
+            'name' => 'SampleUpload',
364
+            'method' => 'myMethod',
365
+            'args' => [],
366
+        ]),
367
+    ])
368
+    ->withUploadedFiles([
369
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
370
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
371
+    ])
372
+    ->withMethod('POST');
373
+});
374
+
375
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
376
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
377
+jaxon()->processRequest();
378
+
379
+// Return the file name for the next test
380
+$aFiles = jaxon()->upload()->files();
381
+$this->assertCount(1, $aFiles);
382
+$this->assertCount(1, $aFiles['image']);
383
+$xFile = $aFiles['image'][0];
384
+$this->assertEquals('white', $xFile->name());
385
+$this->assertEquals($this->sNameWhite, $xFile->filename());
386
+}
387
+
388
+/**
389 389
      * @throws RequestException
390 390
      */
391
-    public function testUploadFileExtensionValidationError()
392
-    {
393
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
394
-        jaxon()->setOption('upload.default.extensions', ['jpg']);
395
-        // Send a request to the registered class
396
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
397
-            return $c->g(ServerRequestCreator::class)
398
-                ->fromGlobals()
399
-                ->withParsedBody([
400
-                    'jxncall' => json_encode([
401
-                        'type' => 'class',
402
-                        'name' => 'SampleUpload',
403
-                        'method' => 'myMethod',
404
-                        'args' => [],
405
-                    ]),
406
-                ])
407
-                ->withUploadedFiles([
408
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
409
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
410
-                ])
411
-                ->withMethod('POST');
412
-        });
413
-
414
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
415
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
416
-        $this->expectException(RequestException::class);
417
-        jaxon()->processRequest();
418
-    }
419
-
420
-    /**
391
+public function testUploadFileExtensionValidationError()
392
+{
393
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
394
+jaxon()->setOption('upload.default.extensions', ['jpg']);
395
+// Send a request to the registered class
396
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
397
+return $c->g(ServerRequestCreator::class)
398
+    ->fromGlobals()
399
+    ->withParsedBody([
400
+        'jxncall' => json_encode([
401
+            'type' => 'class',
402
+            'name' => 'SampleUpload',
403
+            'method' => 'myMethod',
404
+            'args' => [],
405
+        ]),
406
+    ])
407
+    ->withUploadedFiles([
408
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
409
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
410
+    ])
411
+    ->withMethod('POST');
412
+});
413
+
414
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
415
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
416
+$this->expectException(RequestException::class);
417
+jaxon()->processRequest();
418
+}
419
+
420
+/**
421 421
      * @throws RequestException
422 422
      */
423
-    public function testUploadFileMaxSizeValidationOk()
424
-    {
425
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
426
-        jaxon()->setOption('upload.default.max-size', 30000);
427
-        // Send a request to the registered class
428
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
429
-            return $c->g(ServerRequestCreator::class)
430
-                ->fromGlobals()
431
-                ->withParsedBody([
432
-                    'jxncall' => json_encode([
433
-                        'type' => 'class',
434
-                        'name' => 'SampleUpload',
435
-                        'method' => 'myMethod',
436
-                        'args' => [],
437
-                    ]),
438
-                ])
439
-                ->withUploadedFiles([
440
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
441
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
442
-                ])
443
-                ->withMethod('POST');
444
-        });
445
-
446
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
447
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
448
-        jaxon()->processRequest();
449
-
450
-        // Return the file name for the next test
451
-        $aFiles = jaxon()->upload()->files();
452
-        $this->assertCount(1, $aFiles);
453
-        $this->assertCount(1, $aFiles['image']);
454
-        $xFile = $aFiles['image'][0];
455
-        $this->assertEquals('white', $xFile->name());
456
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
457
-    }
458
-
459
-    /**
423
+public function testUploadFileMaxSizeValidationOk()
424
+{
425
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
426
+jaxon()->setOption('upload.default.max-size', 30000);
427
+// Send a request to the registered class
428
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
429
+return $c->g(ServerRequestCreator::class)
430
+    ->fromGlobals()
431
+    ->withParsedBody([
432
+        'jxncall' => json_encode([
433
+            'type' => 'class',
434
+            'name' => 'SampleUpload',
435
+            'method' => 'myMethod',
436
+            'args' => [],
437
+        ]),
438
+    ])
439
+    ->withUploadedFiles([
440
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
441
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
442
+    ])
443
+    ->withMethod('POST');
444
+});
445
+
446
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
447
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
448
+jaxon()->processRequest();
449
+
450
+// Return the file name for the next test
451
+$aFiles = jaxon()->upload()->files();
452
+$this->assertCount(1, $aFiles);
453
+$this->assertCount(1, $aFiles['image']);
454
+$xFile = $aFiles['image'][0];
455
+$this->assertEquals('white', $xFile->name());
456
+$this->assertEquals($this->sNameWhite, $xFile->filename());
457
+}
458
+
459
+/**
460 460
      * @throws RequestException
461 461
      */
462
-    public function testUploadFileMaxSizeValidationError()
463
-    {
464
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
465
-        jaxon()->setOption('upload.default.max-size', 25000);
466
-        // Send a request to the registered class
467
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
468
-            return $c->g(ServerRequestCreator::class)
469
-                ->fromGlobals()
470
-                ->withParsedBody([
471
-                    'jxncall' => json_encode([
472
-                        'type' => 'class',
473
-                        'name' => 'SampleUpload',
474
-                        'method' => 'myMethod',
475
-                        'args' => [],
476
-                    ]),
477
-                ])
478
-                ->withUploadedFiles([
479
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
480
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
481
-                ])
482
-                ->withMethod('POST');
483
-        });
484
-
485
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
486
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
487
-        $this->expectException(RequestException::class);
488
-        jaxon()->processRequest();
489
-    }
490
-
491
-    /**
462
+public function testUploadFileMaxSizeValidationError()
463
+{
464
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
465
+jaxon()->setOption('upload.default.max-size', 25000);
466
+// Send a request to the registered class
467
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
468
+return $c->g(ServerRequestCreator::class)
469
+    ->fromGlobals()
470
+    ->withParsedBody([
471
+        'jxncall' => json_encode([
472
+            'type' => 'class',
473
+            'name' => 'SampleUpload',
474
+            'method' => 'myMethod',
475
+            'args' => [],
476
+        ]),
477
+    ])
478
+    ->withUploadedFiles([
479
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
480
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
481
+    ])
482
+    ->withMethod('POST');
483
+});
484
+
485
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
486
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
487
+$this->expectException(RequestException::class);
488
+jaxon()->processRequest();
489
+}
490
+
491
+/**
492 492
      * @throws RequestException
493 493
      */
494
-    public function testUploadFileMinSizeValidationOk()
495
-    {
496
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
497
-        jaxon()->setOption('upload.default.min-size', 25000);
498
-        // Send a request to the registered class
499
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
500
-            return $c->g(ServerRequestCreator::class)
501
-                ->fromGlobals()
502
-                ->withParsedBody([
503
-                    'jxncall' => json_encode([
504
-                        'type' => 'class',
505
-                        'name' => 'SampleUpload',
506
-                        'method' => 'myMethod',
507
-                        'args' => [],
508
-                    ]),
509
-                ])
510
-                ->withUploadedFiles([
511
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
512
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
513
-                ])
514
-                ->withMethod('POST');
515
-        });
516
-
517
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
518
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
519
-        jaxon()->processRequest();
520
-
521
-        // Return the file name for the next test
522
-        $aFiles = jaxon()->upload()->files();
523
-        $this->assertCount(1, $aFiles);
524
-        $this->assertCount(1, $aFiles['image']);
525
-        $xFile = $aFiles['image'][0];
526
-        $this->assertEquals('white', $xFile->name());
527
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
528
-    }
529
-
530
-    /**
494
+public function testUploadFileMinSizeValidationOk()
495
+{
496
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
497
+jaxon()->setOption('upload.default.min-size', 25000);
498
+// Send a request to the registered class
499
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
500
+return $c->g(ServerRequestCreator::class)
501
+    ->fromGlobals()
502
+    ->withParsedBody([
503
+        'jxncall' => json_encode([
504
+            'type' => 'class',
505
+            'name' => 'SampleUpload',
506
+            'method' => 'myMethod',
507
+            'args' => [],
508
+        ]),
509
+    ])
510
+    ->withUploadedFiles([
511
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
512
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
513
+    ])
514
+    ->withMethod('POST');
515
+});
516
+
517
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
518
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
519
+jaxon()->processRequest();
520
+
521
+// Return the file name for the next test
522
+$aFiles = jaxon()->upload()->files();
523
+$this->assertCount(1, $aFiles);
524
+$this->assertCount(1, $aFiles['image']);
525
+$xFile = $aFiles['image'][0];
526
+$this->assertEquals('white', $xFile->name());
527
+$this->assertEquals($this->sNameWhite, $xFile->filename());
528
+}
529
+
530
+/**
531 531
      * @throws RequestException
532 532
      */
533
-    public function testUploadFileMinSizeValidationError()
534
-    {
535
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
536
-        jaxon()->setOption('upload.default.min-size', 30000);
537
-        // Send a request to the registered class
538
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
539
-            return $c->g(ServerRequestCreator::class)
540
-                ->fromGlobals()
541
-                ->withParsedBody([
542
-                    'jxncall' => json_encode([
543
-                        'type' => 'class',
544
-                        'name' => 'SampleUpload',
545
-                        'method' => 'myMethod',
546
-                        'args' => [],
547
-                    ]),
548
-                ])
549
-                ->withUploadedFiles([
550
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
551
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
552
-                ])
553
-                ->withMethod('POST');
554
-        });
555
-
556
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
557
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
558
-        $this->expectException(RequestException::class);
559
-        jaxon()->processRequest();
560
-    }
561
-
562
-    /**
533
+public function testUploadFileMinSizeValidationError()
534
+{
535
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
536
+jaxon()->setOption('upload.default.min-size', 30000);
537
+// Send a request to the registered class
538
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
539
+return $c->g(ServerRequestCreator::class)
540
+    ->fromGlobals()
541
+    ->withParsedBody([
542
+        'jxncall' => json_encode([
543
+            'type' => 'class',
544
+            'name' => 'SampleUpload',
545
+            'method' => 'myMethod',
546
+            'args' => [],
547
+        ]),
548
+    ])
549
+    ->withUploadedFiles([
550
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
551
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
552
+    ])
553
+    ->withMethod('POST');
554
+});
555
+
556
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
557
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
558
+$this->expectException(RequestException::class);
559
+jaxon()->processRequest();
560
+}
561
+
562
+/**
563 563
      * @throws RequestException
564 564
      * @throws SetupException
565 565
      */
566
-    public function testPsrAjaxUpload()
567
-    {
568
-        _register();
569
-        jaxon()->setOption('core.upload.enabled', true);
570
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
571
-        // Send a request to the registered class
572
-        $xRequest = jaxon()->di()->g(ServerRequestCreator::class)
573
-            ->fromGlobals()
574
-            ->withParsedBody([
575
-                'jxncall' => json_encode([
576
-                    'type' => 'class',
577
-                    'name' => 'SampleUpload',
578
-                    'method' => 'myMethod',
579
-                    'args' => [],
580
-                ]),
581
-            ])
582
-            ->withUploadedFiles([
583
-                'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
584
-                    UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
585
-            ])
586
-            ->withMethod('POST');
587
-
588
-        $xPsrConfigMiddleware = jaxon()->psr()->config(__DIR__ . '/../config/psr.php');
589
-        $xPsrAjaxMiddleware = jaxon()->psr()->ajax();
590
-        // PSR request handler that does nothing, useful to call the config middleware.
591
-        $xEmptyRequestHandler = new class implements RequestHandlerInterface
592
-        {
593
-            private $xPsr17Factory;
594
-
595
-            public function __construct()
596
-            {
597
-                $this->xPsr17Factory = new Psr17Factory();
598
-            }
599
-
600
-            public function handle(ServerRequestInterface $request): ResponseInterface
601
-            {
602
-                return $this->xPsr17Factory->createResponse();
603
-            }
604
-        };
605
-        // Call the config middleware
606
-        $xPsrConfigMiddleware->process($xRequest, $xEmptyRequestHandler);
607
-        // Call the ajax middleware
608
-        $xPsrResponse = $xPsrAjaxMiddleware->process($xRequest, $xEmptyRequestHandler);
609
-
610
-        // Both responses must have the same content and content type
611
-        $xJaxonResponse = jaxon()->getResponse();
612
-        $this->assertEquals($xPsrResponse->getBody()->__toString(), $xJaxonResponse->getOutput());
613
-        $this->assertEquals($xPsrResponse->getHeader('content-type')[0], $xJaxonResponse->getContentType());
614
-
615
-        // Uploaded files
616
-        $aFiles = jaxon()->upload()->files();
617
-        $this->assertCount(1, $aFiles);
618
-        $this->assertCount(1, $aFiles['image']);
619
-        $xFile = $aFiles['image'][0];
620
-        $this->assertEquals('white', $xFile->name());
621
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
622
-        $this->assertEquals('png', $xFile->type());
623
-        $this->assertEquals('png', $xFile->extension());
624
-    }
566
+public function testPsrAjaxUpload()
567
+{
568
+_register();
569
+jaxon()->setOption('core.upload.enabled', true);
570
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
571
+// Send a request to the registered class
572
+$xRequest = jaxon()->di()->g(ServerRequestCreator::class)
573
+->fromGlobals()
574
+->withParsedBody([
575
+    'jxncall' => json_encode([
576
+        'type' => 'class',
577
+        'name' => 'SampleUpload',
578
+        'method' => 'myMethod',
579
+        'args' => [],
580
+    ]),
581
+])
582
+->withUploadedFiles([
583
+    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
584
+        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
585
+])
586
+->withMethod('POST');
587
+
588
+$xPsrConfigMiddleware = jaxon()->psr()->config(__DIR__ . '/../config/psr.php');
589
+$xPsrAjaxMiddleware = jaxon()->psr()->ajax();
590
+// PSR request handler that does nothing, useful to call the config middleware.
591
+$xEmptyRequestHandler = new class implements RequestHandlerInterface
592
+{
593
+private $xPsr17Factory;
594
+
595
+public function __construct()
596
+{
597
+    $this->xPsr17Factory = new Psr17Factory();
598
+}
599
+
600
+public function handle(ServerRequestInterface $request): ResponseInterface
601
+{
602
+    return $this->xPsr17Factory->createResponse();
603
+}
604
+};
605
+// Call the config middleware
606
+$xPsrConfigMiddleware->process($xRequest, $xEmptyRequestHandler);
607
+// Call the ajax middleware
608
+$xPsrResponse = $xPsrAjaxMiddleware->process($xRequest, $xEmptyRequestHandler);
609
+
610
+// Both responses must have the same content and content type
611
+$xJaxonResponse = jaxon()->getResponse();
612
+$this->assertEquals($xPsrResponse->getBody()->__toString(), $xJaxonResponse->getOutput());
613
+$this->assertEquals($xPsrResponse->getHeader('content-type')[0], $xJaxonResponse->getContentType());
614
+
615
+// Uploaded files
616
+$aFiles = jaxon()->upload()->files();
617
+$this->assertCount(1, $aFiles);
618
+$this->assertCount(1, $aFiles['image']);
619
+$xFile = $aFiles['image'][0];
620
+$this->assertEquals('white', $xFile->name());
621
+$this->assertEquals($this->sNameWhite, $xFile->filename());
622
+$this->assertEquals('png', $xFile->type());
623
+$this->assertEquals('png', $xFile->extension());
624
+}
625 625
 }
Please login to merge, or discard this patch.
jaxon-upload/tests/TestUpload/UploadFsLocalTest.php 1 patch
Switch Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -19,166 +19,166 @@
 block discarded – undo
19 19
 
20 20
 class UploadFsLocalTest extends TestCase
21 21
 {
22
-    /**
22
+/**
23 23
      * @var string
24 24
      */
25
-    protected $sNameWhite;
25
+protected $sNameWhite;
26 26
 
27
-    /**
27
+/**
28 28
      * @var string
29 29
      */
30
-    protected $sPathWhite;
30
+protected $sPathWhite;
31 31
 
32
-    /**
32
+/**
33 33
      * @var int
34 34
      */
35
-    protected $sSizeWhite;
35
+protected $sSizeWhite;
36 36
 
37
-    /**
37
+/**
38 38
      * @var string
39 39
      */
40
-    protected $sNameBlue;
40
+protected $sNameBlue;
41 41
 
42
-    /**
42
+/**
43 43
      * @var string
44 44
      */
45
-    protected $sPathBlue;
45
+protected $sPathBlue;
46 46
 
47
-    /**
47
+/**
48 48
      * @var int
49 49
      */
50
-    protected $sSizeBlue;
50
+protected $sSizeBlue;
51 51
 
52
-    /**
52
+/**
53 53
      * @throws SetupException
54 54
      */
55
-    public function setUp(): void
56
-    {
57
-        jaxon()->di()->getPluginManager()->registerPlugins();
58
-        jaxon()->setOption('core.response.send', false);
59
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
60
-        _register();
61
-
62
-        $tmpDir = __DIR__ . '/../upload/tmp';
63
-        @mkdir($tmpDir);
64
-
65
-        $sSrcWhite = __DIR__ . '/../upload/src/white.png';
66
-        $this->sNameWhite = 'white.png';
67
-        $this->sPathWhite = "$tmpDir/{$this->sNameWhite}";
68
-        $this->sSizeWhite = filesize($sSrcWhite);
69
-        // Copy the file to the temp dir.
70
-        @copy($sSrcWhite, $this->sPathWhite);
71
-
72
-        $sSrcBlue = __DIR__ . '/../upload/src/blue.png';
73
-        $this->sNameBlue = 'blue.png';
74
-        $this->sPathBlue = "$tmpDir/{$this->sNameBlue}";
75
-        $this->sSizeBlue = filesize($sSrcBlue);
76
-        // Copy the file to the temp dir.
77
-        @copy($sSrcBlue, $this->sPathBlue);
78
-    }
79
-
80
-    /**
55
+public function setUp(): void
56
+{
57
+jaxon()->di()->getPluginManager()->registerPlugins();
58
+jaxon()->setOption('core.response.send', false);
59
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
60
+_register();
61
+
62
+$tmpDir = __DIR__ . '/../upload/tmp';
63
+@mkdir($tmpDir);
64
+
65
+$sSrcWhite = __DIR__ . '/../upload/src/white.png';
66
+$this->sNameWhite = 'white.png';
67
+$this->sPathWhite = "$tmpDir/{$this->sNameWhite}";
68
+$this->sSizeWhite = filesize($sSrcWhite);
69
+// Copy the file to the temp dir.
70
+@copy($sSrcWhite, $this->sPathWhite);
71
+
72
+$sSrcBlue = __DIR__ . '/../upload/src/blue.png';
73
+$this->sNameBlue = 'blue.png';
74
+$this->sPathBlue = "$tmpDir/{$this->sNameBlue}";
75
+$this->sSizeBlue = filesize($sSrcBlue);
76
+// Copy the file to the temp dir.
77
+@copy($sSrcBlue, $this->sPathBlue);
78
+}
79
+
80
+/**
81 81
      * @throws SetupException
82 82
      */
83
-    public function tearDown(): void
84
-    {
85
-        jaxon()->reset();
86
-        parent::tearDown();
87
-    }
83
+public function tearDown(): void
84
+{
85
+jaxon()->reset();
86
+parent::tearDown();
87
+}
88 88
 
89
-    /**
89
+/**
90 90
      * @throws RequestException
91 91
      */
92
-    public function testHttpUploadDisabled()
93
-    {
94
-        jaxon()->setOption('core.upload.enabled', false);
95
-        jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
96
-        jaxon()->di()->getBootstrap()->onBoot();
97
-
98
-        // Send a request to the registered class
99
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
100
-            return $c->g(ServerRequestCreator::class)
101
-                ->fromGlobals()
102
-                ->withUploadedFiles([
103
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
104
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
105
-                ])
106
-                ->withMethod('POST');
107
-        });
108
-
109
-        $this->assertFalse(jaxon()->di()->getRequestHandler()->canProcessRequest());
110
-    }
111
-
112
-    /**
92
+public function testHttpUploadDisabled()
93
+{
94
+jaxon()->setOption('core.upload.enabled', false);
95
+jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
96
+jaxon()->di()->getBootstrap()->onBoot();
97
+
98
+// Send a request to the registered class
99
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
100
+return $c->g(ServerRequestCreator::class)
101
+    ->fromGlobals()
102
+    ->withUploadedFiles([
103
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
104
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
105
+    ])
106
+    ->withMethod('POST');
107
+});
108
+
109
+$this->assertFalse(jaxon()->di()->getRequestHandler()->canProcessRequest());
110
+}
111
+
112
+/**
113 113
      * @throws RequestException
114 114
      */
115
-    public function testRequestWithNoPluginNoUpload()
116
-    {
117
-        jaxon()->setOption('core.upload.enabled', false);
118
-        jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
119
-        jaxon()->di()->getBootstrap()->onBoot();
120
-
121
-        // Send a request to the registered class
122
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
123
-            return $c->g(ServerRequestCreator::class)
124
-                ->fromGlobals()
125
-                ->withParsedBody([
126
-                    'jxncall' => json_encode([
127
-                        'who' => 'Nobody',
128
-                        'args' => [],
129
-                    ]),
130
-                ])
131
-                ->withMethod('POST');
132
-        });
133
-
134
-        $this->assertFalse(jaxon()->di()->getRequestHandler()->canProcessRequest());
135
-    }
136
-
137
-    /**
115
+public function testRequestWithNoPluginNoUpload()
116
+{
117
+jaxon()->setOption('core.upload.enabled', false);
118
+jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
119
+jaxon()->di()->getBootstrap()->onBoot();
120
+
121
+// Send a request to the registered class
122
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
123
+return $c->g(ServerRequestCreator::class)
124
+    ->fromGlobals()
125
+    ->withParsedBody([
126
+        'jxncall' => json_encode([
127
+            'who' => 'Nobody',
128
+            'args' => [],
129
+        ]),
130
+    ])
131
+    ->withMethod('POST');
132
+});
133
+
134
+$this->assertFalse(jaxon()->di()->getRequestHandler()->canProcessRequest());
135
+}
136
+
137
+/**
138 138
      * @throws RequestException
139 139
      */
140
-    public function testUploadInMemoryStorage()
141
-    {
142
-        jaxon()->setOption('core.upload.enabled', true);
143
-        jaxon()->setOption('upload.default.storage', 'memory');
144
-        jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
145
-        jaxon()->di()->getBootstrap()->onBoot();
146
-
147
-        // In memory file system adapter
148
-        jaxon()->upload()->registerStorageAdapter('memory',
149
-            fn() => new InMemoryFilesystemAdapter());
150
-
151
-        // Send a request to the registered class
152
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
153
-            return $c->g(ServerRequestCreator::class)
154
-                ->fromGlobals()
155
-                ->withParsedBody([
156
-                    'jxncall' => json_encode([
157
-                        'type' => 'class',
158
-                        'name' => 'SampleUpload',
159
-                        'method' => 'myMethod',
160
-                        'args' => [],
161
-                    ]),
162
-                ])
163
-                ->withUploadedFiles([
164
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
165
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
166
-                ])
167
-                ->withMethod('POST');
168
-        });
169
-
170
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
171
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
172
-        jaxon()->processRequest();
173
-
174
-        // Uploaded files
175
-        $aFiles = jaxon()->upload()->files();
176
-        $this->assertCount(1, $aFiles);
177
-        $this->assertCount(1, $aFiles['image']);
178
-        $xFile = $aFiles['image'][0];
179
-        $this->assertEquals('white', $xFile->name());
180
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
181
-        $this->assertEquals('png', $xFile->type());
182
-        $this->assertEquals('png', $xFile->extension());
183
-    }
140
+public function testUploadInMemoryStorage()
141
+{
142
+jaxon()->setOption('core.upload.enabled', true);
143
+jaxon()->setOption('upload.default.storage', 'memory');
144
+jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
145
+jaxon()->di()->getBootstrap()->onBoot();
146
+
147
+// In memory file system adapter
148
+jaxon()->upload()->registerStorageAdapter('memory',
149
+fn() => new InMemoryFilesystemAdapter());
150
+
151
+// Send a request to the registered class
152
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
153
+return $c->g(ServerRequestCreator::class)
154
+    ->fromGlobals()
155
+    ->withParsedBody([
156
+        'jxncall' => json_encode([
157
+            'type' => 'class',
158
+            'name' => 'SampleUpload',
159
+            'method' => 'myMethod',
160
+            'args' => [],
161
+        ]),
162
+    ])
163
+    ->withUploadedFiles([
164
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
165
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
166
+    ])
167
+    ->withMethod('POST');
168
+});
169
+
170
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
171
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
172
+jaxon()->processRequest();
173
+
174
+// Uploaded files
175
+$aFiles = jaxon()->upload()->files();
176
+$this->assertCount(1, $aFiles);
177
+$this->assertCount(1, $aFiles['image']);
178
+$xFile = $aFiles['image'][0];
179
+$this->assertEquals('white', $xFile->name());
180
+$this->assertEquals($this->sNameWhite, $xFile->filename());
181
+$this->assertEquals('png', $xFile->type());
182
+$this->assertEquals('png', $xFile->extension());
183
+}
184 184
 }
Please login to merge, or discard this patch.
jaxon-upload/tests/TestUpload/UploadTest.php 1 patch
Switch Indentation   +508 added lines, -508 removed lines patch added patch discarded remove patch
@@ -16,561 +16,561 @@
 block discarded – undo
16 16
 
17 17
 class UploadTest extends TestCase
18 18
 {
19
-    /**
19
+/**
20 20
      * @var string
21 21
      */
22
-    protected $sNameWhite;
22
+protected $sNameWhite;
23 23
 
24
-    /**
24
+/**
25 25
      * @var string
26 26
      */
27
-    protected $sPathWhite;
27
+protected $sPathWhite;
28 28
 
29
-    /**
29
+/**
30 30
      * @var int
31 31
      */
32
-    protected $sSizeWhite;
32
+protected $sSizeWhite;
33 33
 
34
-    /**
34
+/**
35 35
      * @var string
36 36
      */
37
-    protected $sNameBlue;
37
+protected $sNameBlue;
38 38
 
39
-    /**
39
+/**
40 40
      * @var string
41 41
      */
42
-    protected $sPathBlue;
42
+protected $sPathBlue;
43 43
 
44
-    /**
44
+/**
45 45
      * @var int
46 46
      */
47
-    protected $sSizeBlue;
47
+protected $sSizeBlue;
48 48
 
49
-    /**
49
+/**
50 50
      * @throws SetupException
51 51
      */
52
-    public function setUp(): void
53
-    {
54
-        _register();
55
-        jaxon()->setOption('core.upload.enabled', true);
56
-
57
-        jaxon()->setOption('core.response.send', false);
58
-        $tmpDir = __DIR__ . '/../upload/tmp';
59
-        @mkdir($tmpDir);
60
-
61
-        $sSrcWhite = __DIR__ . '/../upload/src/white.png';
62
-        $this->sNameWhite = 'white.png';
63
-        $this->sPathWhite = "$tmpDir/{$this->sNameWhite}";
64
-        $this->sSizeWhite = filesize($sSrcWhite);
65
-        // Copy the file to the temp dir.
66
-        @copy($sSrcWhite, $this->sPathWhite);
67
-
68
-        $sSrcBlue = __DIR__ . '/../upload/src/blue.png';
69
-        $this->sNameBlue = 'blue.png';
70
-        $this->sPathBlue = "$tmpDir/{$this->sNameBlue}";
71
-        $this->sSizeBlue = filesize($sSrcBlue);
72
-        // Copy the file to the temp dir.
73
-        @copy($sSrcBlue, $this->sPathBlue);
74
-
75
-        jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
76
-        jaxon()->di()->getBootstrap()->onBoot();
77
-    }
78
-
79
-    /**
52
+public function setUp(): void
53
+{
54
+_register();
55
+jaxon()->setOption('core.upload.enabled', true);
56
+
57
+jaxon()->setOption('core.response.send', false);
58
+$tmpDir = __DIR__ . '/../upload/tmp';
59
+@mkdir($tmpDir);
60
+
61
+$sSrcWhite = __DIR__ . '/../upload/src/white.png';
62
+$this->sNameWhite = 'white.png';
63
+$this->sPathWhite = "$tmpDir/{$this->sNameWhite}";
64
+$this->sSizeWhite = filesize($sSrcWhite);
65
+// Copy the file to the temp dir.
66
+@copy($sSrcWhite, $this->sPathWhite);
67
+
68
+$sSrcBlue = __DIR__ . '/../upload/src/blue.png';
69
+$this->sNameBlue = 'blue.png';
70
+$this->sPathBlue = "$tmpDir/{$this->sNameBlue}";
71
+$this->sSizeBlue = filesize($sSrcBlue);
72
+// Copy the file to the temp dir.
73
+@copy($sSrcBlue, $this->sPathBlue);
74
+
75
+jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleUpload', __DIR__ . '/../src/sample.php');
76
+jaxon()->di()->getBootstrap()->onBoot();
77
+}
78
+
79
+/**
80 80
      * @throws SetupException
81 81
      */
82
-    public function tearDown(): void
83
-    {
84
-        jaxon()->reset();
85
-        parent::tearDown();
86
-    }
82
+public function tearDown(): void
83
+{
84
+jaxon()->reset();
85
+parent::tearDown();
86
+}
87 87
 
88
-    /**
88
+/**
89 89
      * @throws RequestException
90 90
      */
91
-    public function testAjaxUpload()
92
-    {
93
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
94
-        // Send a request to the registered class
95
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
96
-            return $c->g(ServerRequestCreator::class)
97
-                ->fromGlobals()
98
-                ->withParsedBody([
99
-                    'jxncall' => json_encode([
100
-                        'type' => 'class',
101
-                        'name' => 'SampleUpload',
102
-                        'method' => 'myMethod',
103
-                        'args' => [],
104
-                    ]),
105
-                ])
106
-                ->withUploadedFiles([
107
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
108
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
109
-                ])
110
-                ->withMethod('POST');
111
-        });
112
-
113
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
114
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
115
-        jaxon()->processRequest();
116
-
117
-        // Uploaded files
118
-        $aFiles = jaxon()->upload()->files();
119
-        $this->assertCount(1, $aFiles);
120
-        $this->assertCount(1, $aFiles['image']);
121
-        $xFile = $aFiles['image'][0];
122
-        $this->assertEquals('white', $xFile->name());
123
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
124
-        $this->assertEquals('png', $xFile->type());
125
-        $this->assertEquals('png', $xFile->extension());
126
-    }
127
-
128
-    /**
91
+public function testAjaxUpload()
92
+{
93
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
94
+// Send a request to the registered class
95
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
96
+return $c->g(ServerRequestCreator::class)
97
+    ->fromGlobals()
98
+    ->withParsedBody([
99
+        'jxncall' => json_encode([
100
+            'type' => 'class',
101
+            'name' => 'SampleUpload',
102
+            'method' => 'myMethod',
103
+            'args' => [],
104
+        ]),
105
+    ])
106
+    ->withUploadedFiles([
107
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
108
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
109
+    ])
110
+    ->withMethod('POST');
111
+});
112
+
113
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
114
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
115
+jaxon()->processRequest();
116
+
117
+// Uploaded files
118
+$aFiles = jaxon()->upload()->files();
119
+$this->assertCount(1, $aFiles);
120
+$this->assertCount(1, $aFiles['image']);
121
+$xFile = $aFiles['image'][0];
122
+$this->assertEquals('white', $xFile->name());
123
+$this->assertEquals($this->sNameWhite, $xFile->filename());
124
+$this->assertEquals('png', $xFile->type());
125
+$this->assertEquals('png', $xFile->extension());
126
+}
127
+
128
+/**
129 129
      * @throws RequestException
130 130
      */
131
-    public function testAjaxUploadMultipleFiles()
132
-    {
133
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
134
-        // Send a request to the registered class
135
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
136
-            return $c->g(ServerRequestCreator::class)
137
-                ->fromGlobals()
138
-                ->withParsedBody([
139
-                    'jxncall' => json_encode([
140
-                        'type' => 'class',
141
-                        'name' => 'SampleUpload',
142
-                        'method' => 'myMethod',
143
-                        'args' => [],
144
-                    ]),
145
-                ])
146
-                ->withUploadedFiles([
147
-                    'image' => [
148
-                        new UploadedFile($this->sPathWhite, $this->sSizeWhite,
149
-                            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
150
-                        new UploadedFile($this->sPathBlue, $this->sSizeBlue,
151
-                            UPLOAD_ERR_OK, $this->sNameBlue, 'png'),
152
-                    ],
153
-                ])
154
-                ->withMethod('POST');
155
-        });
156
-
157
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
158
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
159
-        jaxon()->processRequest();
160
-
161
-        // Uploaded files
162
-        $aFiles = jaxon()->upload()->files();
163
-        $this->assertCount(1, $aFiles);
164
-        $this->assertCount(2, $aFiles['image']);
165
-        $xFile = $aFiles['image'][0];
166
-        $this->assertEquals('white', $xFile->name());
167
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
168
-        $this->assertEquals('png', $xFile->type());
169
-        $this->assertEquals('png', $xFile->extension());
170
-        $xFile = $aFiles['image'][1];
171
-        $this->assertEquals('blue', $xFile->name());
172
-        $this->assertEquals($this->sNameBlue, $xFile->filename());
173
-        $this->assertEquals('png', $xFile->type());
174
-        $this->assertEquals('png', $xFile->extension());
175
-    }
176
-
177
-    /**
131
+public function testAjaxUploadMultipleFiles()
132
+{
133
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
134
+// Send a request to the registered class
135
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
136
+return $c->g(ServerRequestCreator::class)
137
+    ->fromGlobals()
138
+    ->withParsedBody([
139
+        'jxncall' => json_encode([
140
+            'type' => 'class',
141
+            'name' => 'SampleUpload',
142
+            'method' => 'myMethod',
143
+            'args' => [],
144
+        ]),
145
+    ])
146
+    ->withUploadedFiles([
147
+        'image' => [
148
+            new UploadedFile($this->sPathWhite, $this->sSizeWhite,
149
+                UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
150
+            new UploadedFile($this->sPathBlue, $this->sSizeBlue,
151
+                UPLOAD_ERR_OK, $this->sNameBlue, 'png'),
152
+        ],
153
+    ])
154
+    ->withMethod('POST');
155
+});
156
+
157
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
158
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
159
+jaxon()->processRequest();
160
+
161
+// Uploaded files
162
+$aFiles = jaxon()->upload()->files();
163
+$this->assertCount(1, $aFiles);
164
+$this->assertCount(2, $aFiles['image']);
165
+$xFile = $aFiles['image'][0];
166
+$this->assertEquals('white', $xFile->name());
167
+$this->assertEquals($this->sNameWhite, $xFile->filename());
168
+$this->assertEquals('png', $xFile->type());
169
+$this->assertEquals('png', $xFile->extension());
170
+$xFile = $aFiles['image'][1];
171
+$this->assertEquals('blue', $xFile->name());
172
+$this->assertEquals($this->sNameBlue, $xFile->filename());
173
+$this->assertEquals('png', $xFile->type());
174
+$this->assertEquals('png', $xFile->extension());
175
+}
176
+
177
+/**
178 178
      * @throws RequestException
179 179
      */
180
-    public function testAjaxUploadMultipleNames()
181
-    {
182
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
183
-        // Send a request to the registered class
184
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
185
-            return $c->g(ServerRequestCreator::class)
186
-                ->fromGlobals()
187
-                ->withParsedBody([
188
-                    'jxncall' => json_encode([
189
-                        'type' => 'class',
190
-                        'name' => 'SampleUpload',
191
-                        'method' => 'myMethod',
192
-                        'args' => [],
193
-                    ]),
194
-                ])
195
-                ->withUploadedFiles([
196
-                    'white' => [
197
-                        new UploadedFile($this->sPathWhite, $this->sSizeWhite,
198
-                            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
199
-                    ],
200
-                    'blue' => [
201
-                        new UploadedFile($this->sPathBlue, $this->sSizeBlue,
202
-                            UPLOAD_ERR_OK, $this->sNameBlue, 'png'),
203
-                    ],
204
-                ])
205
-                ->withMethod('POST');
206
-        });
207
-
208
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
209
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
210
-        jaxon()->processRequest();
211
-
212
-        // Uploaded files
213
-        $aFiles = jaxon()->upload()->files();
214
-        $this->assertCount(2, $aFiles);
215
-        $this->assertCount(1, $aFiles['white']);
216
-        $this->assertCount(1, $aFiles['blue']);
217
-        $xFile = $aFiles['white'][0];
218
-        $this->assertEquals('white', $xFile->name());
219
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
220
-        $this->assertEquals('png', $xFile->type());
221
-        $this->assertEquals('png', $xFile->extension());
222
-        $xFile = $aFiles['blue'][0];
223
-        $this->assertEquals('blue', $xFile->name());
224
-        $this->assertEquals($this->sNameBlue, $xFile->filename());
225
-        $this->assertEquals('png', $xFile->type());
226
-        $this->assertEquals('png', $xFile->extension());
227
-    }
228
-
229
-    /**
180
+public function testAjaxUploadMultipleNames()
181
+{
182
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
183
+// Send a request to the registered class
184
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
185
+return $c->g(ServerRequestCreator::class)
186
+    ->fromGlobals()
187
+    ->withParsedBody([
188
+        'jxncall' => json_encode([
189
+            'type' => 'class',
190
+            'name' => 'SampleUpload',
191
+            'method' => 'myMethod',
192
+            'args' => [],
193
+        ]),
194
+    ])
195
+    ->withUploadedFiles([
196
+        'white' => [
197
+            new UploadedFile($this->sPathWhite, $this->sSizeWhite,
198
+                UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
199
+        ],
200
+        'blue' => [
201
+            new UploadedFile($this->sPathBlue, $this->sSizeBlue,
202
+                UPLOAD_ERR_OK, $this->sNameBlue, 'png'),
203
+        ],
204
+    ])
205
+    ->withMethod('POST');
206
+});
207
+
208
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
209
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
210
+jaxon()->processRequest();
211
+
212
+// Uploaded files
213
+$aFiles = jaxon()->upload()->files();
214
+$this->assertCount(2, $aFiles);
215
+$this->assertCount(1, $aFiles['white']);
216
+$this->assertCount(1, $aFiles['blue']);
217
+$xFile = $aFiles['white'][0];
218
+$this->assertEquals('white', $xFile->name());
219
+$this->assertEquals($this->sNameWhite, $xFile->filename());
220
+$this->assertEquals('png', $xFile->type());
221
+$this->assertEquals('png', $xFile->extension());
222
+$xFile = $aFiles['blue'][0];
223
+$this->assertEquals('blue', $xFile->name());
224
+$this->assertEquals($this->sNameBlue, $xFile->filename());
225
+$this->assertEquals('png', $xFile->type());
226
+$this->assertEquals('png', $xFile->extension());
227
+}
228
+
229
+/**
230 230
      * @throws RequestException
231 231
      */
232
-    public function testAjaxUploadNameSanitizer()
233
-    {
234
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
235
-        jaxon()->upload()->sanitizer(function($sFilename, $sVarName) {
236
-            return $sVarName === 'image' ? 'img_' . $sFilename : $sFilename;
237
-        });
238
-        // Send a request to the registered class
239
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
240
-            return $c->g(ServerRequestCreator::class)
241
-                ->fromGlobals()
242
-                ->withParsedBody([
243
-                    'jxncall' => json_encode([
244
-                        'type' => 'class',
245
-                        'name' => 'SampleUpload',
246
-                        'method' => 'myMethod',
247
-                        'args' => [],
248
-                    ]),
249
-                ])
250
-                ->withUploadedFiles([
251
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
252
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
253
-                ])
254
-                ->withMethod('POST');
255
-        });
256
-
257
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
258
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
259
-        jaxon()->processRequest();
260
-
261
-        // Uploaded files
262
-        $aFiles = jaxon()->upload()->files();
263
-        $this->assertCount(1, $aFiles);
264
-        $this->assertCount(1, $aFiles['image']);
265
-        $xFile = $aFiles['image'][0];
266
-        $this->assertEquals('img_white', $xFile->name());
267
-        $this->assertEquals('png', $xFile->type());
268
-        $this->assertEquals('png', $xFile->extension());
269
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
270
-    }
271
-
272
-    /**
232
+public function testAjaxUploadNameSanitizer()
233
+{
234
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
235
+jaxon()->upload()->sanitizer(function($sFilename, $sVarName) {
236
+return $sVarName === 'image' ? 'img_' . $sFilename : $sFilename;
237
+});
238
+// Send a request to the registered class
239
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
240
+return $c->g(ServerRequestCreator::class)
241
+    ->fromGlobals()
242
+    ->withParsedBody([
243
+        'jxncall' => json_encode([
244
+            'type' => 'class',
245
+            'name' => 'SampleUpload',
246
+            'method' => 'myMethod',
247
+            'args' => [],
248
+        ]),
249
+    ])
250
+    ->withUploadedFiles([
251
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
252
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
253
+    ])
254
+    ->withMethod('POST');
255
+});
256
+
257
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
258
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
259
+jaxon()->processRequest();
260
+
261
+// Uploaded files
262
+$aFiles = jaxon()->upload()->files();
263
+$this->assertCount(1, $aFiles);
264
+$this->assertCount(1, $aFiles['image']);
265
+$xFile = $aFiles['image'][0];
266
+$this->assertEquals('img_white', $xFile->name());
267
+$this->assertEquals('png', $xFile->type());
268
+$this->assertEquals('png', $xFile->extension());
269
+$this->assertEquals($this->sNameWhite, $xFile->filename());
270
+}
271
+
272
+/**
273 273
      * @throws RequestException
274 274
      */
275
-    public function testUploadFileTypeValidationOk()
276
-    {
277
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
278
-        jaxon()->setOption('upload.default.types', ['png']);
279
-        // Send a request to the registered class
280
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
281
-            return $c->g(ServerRequestCreator::class)
282
-                ->fromGlobals()
283
-                ->withParsedBody([
284
-                    'jxncall' => json_encode([
285
-                        'type' => 'class',
286
-                        'name' => 'SampleUpload',
287
-                        'method' => 'myMethod',
288
-                        'args' => [],
289
-                    ]),
290
-                ])
291
-                ->withUploadedFiles([
292
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
293
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
294
-                ])->withMethod('POST');
295
-        });
296
-
297
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
298
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
299
-        jaxon()->processRequest();
300
-
301
-        // Return the file name for the next test
302
-        $aFiles = jaxon()->upload()->files();
303
-        $this->assertCount(1, $aFiles);
304
-        $this->assertCount(1, $aFiles['image']);
305
-        $xFile = $aFiles['image'][0];
306
-        $this->assertEquals('white', $xFile->name());
307
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
308
-    }
309
-
310
-    /**
275
+public function testUploadFileTypeValidationOk()
276
+{
277
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
278
+jaxon()->setOption('upload.default.types', ['png']);
279
+// Send a request to the registered class
280
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
281
+return $c->g(ServerRequestCreator::class)
282
+    ->fromGlobals()
283
+    ->withParsedBody([
284
+        'jxncall' => json_encode([
285
+            'type' => 'class',
286
+            'name' => 'SampleUpload',
287
+            'method' => 'myMethod',
288
+            'args' => [],
289
+        ]),
290
+    ])
291
+    ->withUploadedFiles([
292
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
293
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
294
+    ])->withMethod('POST');
295
+});
296
+
297
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
298
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
299
+jaxon()->processRequest();
300
+
301
+// Return the file name for the next test
302
+$aFiles = jaxon()->upload()->files();
303
+$this->assertCount(1, $aFiles);
304
+$this->assertCount(1, $aFiles['image']);
305
+$xFile = $aFiles['image'][0];
306
+$this->assertEquals('white', $xFile->name());
307
+$this->assertEquals($this->sNameWhite, $xFile->filename());
308
+}
309
+
310
+/**
311 311
      * @throws RequestException
312 312
      */
313
-    public function testUploadFileTypeValidationError()
314
-    {
315
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
316
-        jaxon()->setOption('upload.default.types', ['jpg']);
317
-        // Send a request to the registered class
318
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
319
-            return $c->g(ServerRequestCreator::class)
320
-                ->fromGlobals()
321
-                ->withParsedBody([
322
-                    'jxncall' => json_encode([
323
-                        'type' => 'class',
324
-                        'name' => 'SampleUpload',
325
-                        'method' => 'myMethod',
326
-                        'args' => [],
327
-                    ]),
328
-                ])
329
-                ->withUploadedFiles([
330
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
331
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
332
-                ])
333
-                ->withMethod('POST');
334
-        });
335
-
336
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
337
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
338
-        $this->expectException(RequestException::class);
339
-        jaxon()->processRequest();
340
-    }
341
-
342
-    /**
313
+public function testUploadFileTypeValidationError()
314
+{
315
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
316
+jaxon()->setOption('upload.default.types', ['jpg']);
317
+// Send a request to the registered class
318
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
319
+return $c->g(ServerRequestCreator::class)
320
+    ->fromGlobals()
321
+    ->withParsedBody([
322
+        'jxncall' => json_encode([
323
+            'type' => 'class',
324
+            'name' => 'SampleUpload',
325
+            'method' => 'myMethod',
326
+            'args' => [],
327
+        ]),
328
+    ])
329
+    ->withUploadedFiles([
330
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
331
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
332
+    ])
333
+    ->withMethod('POST');
334
+});
335
+
336
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
337
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
338
+$this->expectException(RequestException::class);
339
+jaxon()->processRequest();
340
+}
341
+
342
+/**
343 343
      * @throws RequestException
344 344
      */
345
-    public function testUploadFileExtensionValidationOk()
346
-    {
347
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
348
-        jaxon()->setOption('upload.default.extensions', ['png']);
349
-        // Send a request to the registered class
350
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
351
-            return $c->g(ServerRequestCreator::class)
352
-                ->fromGlobals()
353
-                ->withParsedBody([
354
-                    'jxncall' => json_encode([
355
-                        'type' => 'class',
356
-                        'name' => 'SampleUpload',
357
-                        'method' => 'myMethod',
358
-                        'args' => [],
359
-                    ]),
360
-                ])
361
-                ->withUploadedFiles([
362
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
363
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
364
-                ])
365
-                ->withMethod('POST');
366
-        });
367
-
368
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
369
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
370
-        jaxon()->processRequest();
371
-
372
-        // Return the file name for the next test
373
-        $aFiles = jaxon()->upload()->files();
374
-        $this->assertCount(1, $aFiles);
375
-        $this->assertCount(1, $aFiles['image']);
376
-        $xFile = $aFiles['image'][0];
377
-        $this->assertEquals('white', $xFile->name());
378
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
379
-    }
380
-
381
-    /**
345
+public function testUploadFileExtensionValidationOk()
346
+{
347
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
348
+jaxon()->setOption('upload.default.extensions', ['png']);
349
+// Send a request to the registered class
350
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
351
+return $c->g(ServerRequestCreator::class)
352
+    ->fromGlobals()
353
+    ->withParsedBody([
354
+        'jxncall' => json_encode([
355
+            'type' => 'class',
356
+            'name' => 'SampleUpload',
357
+            'method' => 'myMethod',
358
+            'args' => [],
359
+        ]),
360
+    ])
361
+    ->withUploadedFiles([
362
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
363
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
364
+    ])
365
+    ->withMethod('POST');
366
+});
367
+
368
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
369
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
370
+jaxon()->processRequest();
371
+
372
+// Return the file name for the next test
373
+$aFiles = jaxon()->upload()->files();
374
+$this->assertCount(1, $aFiles);
375
+$this->assertCount(1, $aFiles['image']);
376
+$xFile = $aFiles['image'][0];
377
+$this->assertEquals('white', $xFile->name());
378
+$this->assertEquals($this->sNameWhite, $xFile->filename());
379
+}
380
+
381
+/**
382 382
      * @throws RequestException
383 383
      */
384
-    public function testUploadFileExtensionValidationError()
385
-    {
386
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
387
-        jaxon()->setOption('upload.default.extensions', ['jpg']);
388
-        // Send a request to the registered class
389
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
390
-            return $c->g(ServerRequestCreator::class)
391
-                ->fromGlobals()
392
-                ->withParsedBody([
393
-                    'jxncall' => json_encode([
394
-                        'type' => 'class',
395
-                        'name' => 'SampleUpload',
396
-                        'method' => 'myMethod',
397
-                        'args' => [],
398
-                    ]),
399
-                ])
400
-                ->withUploadedFiles([
401
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
402
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
403
-                ])
404
-                ->withMethod('POST');
405
-        });
406
-
407
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
408
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
409
-        $this->expectException(RequestException::class);
410
-        jaxon()->processRequest();
411
-    }
412
-
413
-    /**
384
+public function testUploadFileExtensionValidationError()
385
+{
386
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
387
+jaxon()->setOption('upload.default.extensions', ['jpg']);
388
+// Send a request to the registered class
389
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
390
+return $c->g(ServerRequestCreator::class)
391
+    ->fromGlobals()
392
+    ->withParsedBody([
393
+        'jxncall' => json_encode([
394
+            'type' => 'class',
395
+            'name' => 'SampleUpload',
396
+            'method' => 'myMethod',
397
+            'args' => [],
398
+        ]),
399
+    ])
400
+    ->withUploadedFiles([
401
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
402
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
403
+    ])
404
+    ->withMethod('POST');
405
+});
406
+
407
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
408
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
409
+$this->expectException(RequestException::class);
410
+jaxon()->processRequest();
411
+}
412
+
413
+/**
414 414
      * @throws RequestException
415 415
      */
416
-    public function testUploadFileMaxSizeValidationOk()
417
-    {
418
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
419
-        jaxon()->setOption('upload.default.max-size', 30000);
420
-        // Send a request to the registered class
421
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
422
-            return $c->g(ServerRequestCreator::class)
423
-                ->fromGlobals()
424
-                ->withParsedBody([
425
-                    'jxncall' => json_encode([
426
-                        'type' => 'class',
427
-                        'name' => 'SampleUpload',
428
-                        'method' => 'myMethod',
429
-                        'args' => [],
430
-                    ]),
431
-                ])
432
-                ->withUploadedFiles([
433
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
434
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
435
-                ])
436
-                ->withMethod('POST');
437
-        });
438
-
439
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
440
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
441
-        jaxon()->processRequest();
442
-
443
-        // Return the file name for the next test
444
-        $aFiles = jaxon()->upload()->files();
445
-        $this->assertCount(1, $aFiles);
446
-        $this->assertCount(1, $aFiles['image']);
447
-        $xFile = $aFiles['image'][0];
448
-        $this->assertEquals('white', $xFile->name());
449
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
450
-    }
451
-
452
-    /**
416
+public function testUploadFileMaxSizeValidationOk()
417
+{
418
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
419
+jaxon()->setOption('upload.default.max-size', 30000);
420
+// Send a request to the registered class
421
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
422
+return $c->g(ServerRequestCreator::class)
423
+    ->fromGlobals()
424
+    ->withParsedBody([
425
+        'jxncall' => json_encode([
426
+            'type' => 'class',
427
+            'name' => 'SampleUpload',
428
+            'method' => 'myMethod',
429
+            'args' => [],
430
+        ]),
431
+    ])
432
+    ->withUploadedFiles([
433
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
434
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
435
+    ])
436
+    ->withMethod('POST');
437
+});
438
+
439
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
440
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
441
+jaxon()->processRequest();
442
+
443
+// Return the file name for the next test
444
+$aFiles = jaxon()->upload()->files();
445
+$this->assertCount(1, $aFiles);
446
+$this->assertCount(1, $aFiles['image']);
447
+$xFile = $aFiles['image'][0];
448
+$this->assertEquals('white', $xFile->name());
449
+$this->assertEquals($this->sNameWhite, $xFile->filename());
450
+}
451
+
452
+/**
453 453
      * @throws RequestException
454 454
      */
455
-    public function testUploadFileMaxSizeValidationError()
456
-    {
457
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
458
-        jaxon()->setOption('upload.default.max-size', 25000);
459
-        // Send a request to the registered class
460
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
461
-            return $c->g(ServerRequestCreator::class)
462
-                ->fromGlobals()
463
-                ->withParsedBody([
464
-                    'jxncall' => json_encode([
465
-                        'type' => 'class',
466
-                        'name' => 'SampleUpload',
467
-                        'method' => 'myMethod',
468
-                        'args' => [],
469
-                    ]),
470
-                ])
471
-                ->withUploadedFiles([
472
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
473
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
474
-                ])
475
-                ->withMethod('POST');
476
-        });
477
-
478
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
479
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
480
-        $this->expectException(RequestException::class);
481
-        jaxon()->processRequest();
482
-    }
483
-
484
-    /**
455
+public function testUploadFileMaxSizeValidationError()
456
+{
457
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
458
+jaxon()->setOption('upload.default.max-size', 25000);
459
+// Send a request to the registered class
460
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
461
+return $c->g(ServerRequestCreator::class)
462
+    ->fromGlobals()
463
+    ->withParsedBody([
464
+        'jxncall' => json_encode([
465
+            'type' => 'class',
466
+            'name' => 'SampleUpload',
467
+            'method' => 'myMethod',
468
+            'args' => [],
469
+        ]),
470
+    ])
471
+    ->withUploadedFiles([
472
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
473
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
474
+    ])
475
+    ->withMethod('POST');
476
+});
477
+
478
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
479
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
480
+$this->expectException(RequestException::class);
481
+jaxon()->processRequest();
482
+}
483
+
484
+/**
485 485
      * @throws RequestException
486 486
      */
487
-    public function testUploadFileMinSizeValidationOk()
488
-    {
489
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
490
-        jaxon()->setOption('upload.default.min-size', 25000);
491
-        // Send a request to the registered class
492
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
493
-            return $c->g(ServerRequestCreator::class)
494
-                ->fromGlobals()
495
-                ->withParsedBody([
496
-                    'jxncall' => json_encode([
497
-                        'type' => 'class',
498
-                        'name' => 'SampleUpload',
499
-                        'method' => 'myMethod',
500
-                        'args' => [],
501
-                    ]),
502
-                ])
503
-                ->withUploadedFiles([
504
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
505
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
506
-                ])
507
-                ->withMethod('POST');
508
-        });
509
-
510
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
511
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
512
-        jaxon()->processRequest();
513
-
514
-        // Return the file name for the next test
515
-        $aFiles = jaxon()->upload()->files();
516
-        $this->assertCount(1, $aFiles);
517
-        $this->assertCount(1, $aFiles['image']);
518
-        $xFile = $aFiles['image'][0];
519
-        $this->assertEquals('white', $xFile->name());
520
-        $this->assertEquals($this->sNameWhite, $xFile->filename());
521
-    }
522
-
523
-    /**
487
+public function testUploadFileMinSizeValidationOk()
488
+{
489
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
490
+jaxon()->setOption('upload.default.min-size', 25000);
491
+// Send a request to the registered class
492
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
493
+return $c->g(ServerRequestCreator::class)
494
+    ->fromGlobals()
495
+    ->withParsedBody([
496
+        'jxncall' => json_encode([
497
+            'type' => 'class',
498
+            'name' => 'SampleUpload',
499
+            'method' => 'myMethod',
500
+            'args' => [],
501
+        ]),
502
+    ])
503
+    ->withUploadedFiles([
504
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
505
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
506
+    ])
507
+    ->withMethod('POST');
508
+});
509
+
510
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
511
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
512
+jaxon()->processRequest();
513
+
514
+// Return the file name for the next test
515
+$aFiles = jaxon()->upload()->files();
516
+$this->assertCount(1, $aFiles);
517
+$this->assertCount(1, $aFiles['image']);
518
+$xFile = $aFiles['image'][0];
519
+$this->assertEquals('white', $xFile->name());
520
+$this->assertEquals($this->sNameWhite, $xFile->filename());
521
+}
522
+
523
+/**
524 524
      * @throws RequestException
525 525
      */
526
-    public function testUploadFileMinSizeValidationError()
527
-    {
528
-        jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
529
-        jaxon()->setOption('upload.default.min-size', 30000);
530
-        // Send a request to the registered class
531
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
532
-            return $c->g(ServerRequestCreator::class)
533
-                ->fromGlobals()
534
-                ->withParsedBody([
535
-                    'jxncall' => json_encode([
536
-                        'type' => 'class',
537
-                        'name' => 'SampleUpload',
538
-                        'method' => 'myMethod',
539
-                        'args' => [],
540
-                    ]),
541
-                ])
542
-                ->withUploadedFiles([
543
-                    'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
544
-                        UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
545
-                ])
546
-                ->withMethod('POST');
547
-        });
548
-
549
-        $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
550
-        $this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
551
-        $this->expectException(RequestException::class);
552
-        jaxon()->processRequest();
553
-    }
554
-
555
-    /**
526
+public function testUploadFileMinSizeValidationError()
527
+{
528
+jaxon()->setOption('upload.default.dir', __DIR__ . '/../upload/dst');
529
+jaxon()->setOption('upload.default.min-size', 30000);
530
+// Send a request to the registered class
531
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
532
+return $c->g(ServerRequestCreator::class)
533
+    ->fromGlobals()
534
+    ->withParsedBody([
535
+        'jxncall' => json_encode([
536
+            'type' => 'class',
537
+            'name' => 'SampleUpload',
538
+            'method' => 'myMethod',
539
+            'args' => [],
540
+        ]),
541
+    ])
542
+    ->withUploadedFiles([
543
+        'image' => new UploadedFile($this->sPathWhite, $this->sSizeWhite,
544
+            UPLOAD_ERR_OK, $this->sNameWhite, 'png'),
545
+    ])
546
+    ->withMethod('POST');
547
+});
548
+
549
+$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
550
+$this->assertTrue(jaxon()->di()->getUploadHandler()->canProcessRequest(jaxon()->di()->getRequest()));
551
+$this->expectException(RequestException::class);
552
+jaxon()->processRequest();
553
+}
554
+
555
+/**
556 556
      * @throws RequestException
557 557
      */
558
-    public function testRequestWithNoPluginNoUpload()
559
-    {
560
-        jaxon()->setOption('core.upload.enabled', false);
561
-        // Send a request to the registered class
562
-        jaxon()->di()->set(ServerRequestInterface::class, function($c) {
563
-            return $c->g(ServerRequestCreator::class)
564
-                ->fromGlobals()
565
-                ->withParsedBody([
566
-                    'jxncall' => json_encode([
567
-                        'who' => 'Nobody',
568
-                        'args' => [],
569
-                    ]),
570
-                ])
571
-                ->withMethod('POST');
572
-        });
573
-
574
-        $this->assertFalse(jaxon()->di()->getRequestHandler()->canProcessRequest());
575
-    }
558
+public function testRequestWithNoPluginNoUpload()
559
+{
560
+jaxon()->setOption('core.upload.enabled', false);
561
+// Send a request to the registered class
562
+jaxon()->di()->set(ServerRequestInterface::class, function($c) {
563
+return $c->g(ServerRequestCreator::class)
564
+    ->fromGlobals()
565
+    ->withParsedBody([
566
+        'jxncall' => json_encode([
567
+            'who' => 'Nobody',
568
+            'args' => [],
569
+        ]),
570
+    ])
571
+    ->withMethod('POST');
572
+});
573
+
574
+$this->assertFalse(jaxon()->di()->getRequestHandler()->canProcessRequest());
575
+}
576 576
 }
Please login to merge, or discard this patch.