‪TYPO3CMS  9.5
ServerRequestFactoryTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class ‪ServerRequestFactoryTest extends UnitTestCase
26 {
31  {
32  $_SERVER['HTTP_HOST'] = 'localhost';
33  $_SERVER['REQUEST_URI'] = '/index.php';
34  $_SERVER['REMOTE_ADDR'] = '';
35  $_SERVER['SSL_SESSION_ID'] = '';
36  $_FILES = [
37  'tx_uploadexample_piexample' => [
38  'name' => [
39  'newExample' => [
40  'image' => 'o51pb.jpg',
41  'imageCollection' => [
42  0 => 'composer.json',
43  ],
44  ],
45  ],
46  'type' => [
47  'newExample' => [
48  'image' => 'image/jpeg',
49  'imageCollection' => [
50  0 => 'application/json'
51  ]
52  ]
53  ],
54  'tmp_name' => [
55  'newExample' => [
56  'image' => '/Applications/MAMP/tmp/php/phphXdbcd',
57  'imageCollection' => [
58  0 => '/Applications/MAMP/tmp/php/phpgrZ4bb'
59  ]
60  ]
61  ],
62  'error' => [
63  'newExample' => [
64  'image' => 0,
65  'imageCollection' => [
66  0 => 0
67  ]
68  ]
69  ],
70  'size' => [
71  'newExample' => [
72  'image' => 59065,
73  'imageCollection' => [
74  0 => 683
75  ]
76  ]
77  ]
78  ]
79  ];
80 
82 
83  $this->assertNotEmpty($uploadedFiles['tx_uploadexample_piexample']['newExample']['image']);
84  $this->assertTrue($uploadedFiles['tx_uploadexample_piexample']['newExample']['image'] instanceof ‪UploadedFile);
85  $this->assertNotEmpty($uploadedFiles['tx_uploadexample_piexample']['newExample']['imageCollection'][0]);
86  $this->assertTrue($uploadedFiles['tx_uploadexample_piexample']['newExample']['imageCollection'][0] instanceof ‪UploadedFile);
87  }
88 
93  {
94  $_SERVER['HTTP_HOST'] = 'localhost';
95  $_SERVER['REQUEST_URI'] = '/index.php';
96  $_SERVER['REMOTE_ADDR'] = '';
97  $_SERVER['SSL_SESSION_ID'] = '';
98  $_FILES = [];
99 
101 
102  $this->assertEmpty($uploadedFiles);
103  }
104 
109  {
110  $_SERVER['HTTP_HOST'] = 'localhost';
111  $_SERVER['REQUEST_URI'] = '/index.php';
112  $_SERVER['REMOTE_ADDR'] = '';
113  $_SERVER['SSL_SESSION_ID'] = '';
114  $_FILES = [
115  'tx_uploadexample_piexample' => [
116  'name' => '',
117  'tmp_name' => '',
118  'error' => 4,
119  'size' => 0,
120  ],
121  ];
122 
124 
125  $this->assertEmpty($uploadedFiles);
126  }
127 }
‪TYPO3\CMS\Core\Tests\Unit\Http
‪TYPO3\CMS\Core\Tests\Unit\Http\ServerRequestFactoryTest\uploadedFilesAreNormalizedFromFilesSuperGlobal
‪uploadedFilesAreNormalizedFromFilesSuperGlobal()
Definition: ServerRequestFactoryTest.php:30
‪TYPO3\CMS\Core\Tests\Unit\Http\ServerRequestFactoryTest\uploadedFilesAreNotCreatedIfTmpNameIsEmpty
‪uploadedFilesAreNotCreatedIfTmpNameIsEmpty()
Definition: ServerRequestFactoryTest.php:108
‪TYPO3\CMS\Core\Tests\Unit\Http\ServerRequestFactoryTest
Definition: ServerRequestFactoryTest.php:26
‪TYPO3\CMS\Core\Http\ServerRequestFactory
Definition: ServerRequestFactory.php:28
‪TYPO3\CMS\Core\Http\ServerRequest\getUploadedFiles
‪array getUploadedFiles()
Definition: ServerRequest.php:194
‪TYPO3\CMS\Core\Tests\Unit\Http\ServerRequestFactoryTest\uploadedFilesAreNotCreatedForEmptyFilesArray
‪uploadedFilesAreNotCreatedForEmptyFilesArray()
Definition: ServerRequestFactoryTest.php:92
‪TYPO3\CMS\Core\Http\UploadedFile
Definition: UploadedFile.php:31
‪TYPO3\CMS\Core\Http\ServerRequestFactory\fromGlobals
‪static ServerRequest fromGlobals()
Definition: ServerRequestFactory.php:36