2 declare(strict_types = 1);
18 use TYPO3\PharStreamWrapper\Exception;
19 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
29 'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_resources' =>
'typo3conf/ext/test_resources',
30 'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_resources/bundle.phar' =>
'fileadmin/bundle.phar',
33 protected function setUp()
36 if (!in_array(
'phar', stream_get_wrappers())) {
37 $this->markTestSkipped(
'Phar stream wrapper is not registered');
46 $allowedPath =
'typo3conf/ext/test_resources/bundle.phar';
51 [
'Classes',
'Resources']
53 'Classes/Domain/Model directory' => [
54 $allowedPath .
'/Classes/Domain/Model',
57 'Resources directory' => [
58 $allowedPath .
'/Resources',
72 $path = $this->instancePath .
'/' . $path;
73 $handle = opendir(
'phar://' . $path);
74 self::assertInternalType(
'resource', $handle);
86 $path = $this->instancePath .
'/' . $path;
89 $handle = opendir(
'phar://' . $path);
90 while (
false !== $item = readdir($handle)) {
94 self::assertSame($expectation, $items);
106 $path = $this->instancePath .
'/' . $path;
108 $handle = opendir(
'phar://' . $path);
111 self::assertFalse(is_resource($handle));
116 $deniedPath =
'fileadmin/bundle.phar';
119 'root directory' => [
121 [
'Classes',
'Resources']
123 'Classes/Domain/Model directory' => [
124 $deniedPath .
'/Classes/Domain/Model',
127 'Resources directory' => [
128 $deniedPath .
'/Resources',
142 self::expectException(Exception::class);
143 self::expectExceptionCode(1530103998);
145 $path = $this->instancePath .
'/' . $path;
146 opendir(
'phar://' . $path);
154 $allowedPath =
'typo3conf/ext/test_resources/bundle.phar';
157 'filesize base file' => [
162 'filesize Resources/content.txt' => [
164 $allowedPath .
'/Resources/content.txt',
167 'is_file base file' => [
172 'is_file Resources/content.txt' => [
174 $allowedPath .
'/Resources/content.txt',
177 'is_dir base file' => [
182 'is_dir Resources/content.txt' => [
184 $allowedPath .
'/Resources/content.txt',
187 'file_exists base file' => [
192 'file_exists Resources/content.txt' => [
194 $allowedPath .
'/Resources/content.txt',
210 $path = $this->instancePath .
'/' . $path;
214 call_user_func($functionName,
'phar://' . $path)
223 $deniedPath =
'fileadmin/bundle.phar';
226 'filesize base file' => [
231 'filesize Resources/content.txt' => [
233 $deniedPath .
'/Resources/content.txt',
236 'is_file base file' => [
241 'is_file Resources/content.txt' => [
243 $deniedPath .
'/Resources/content.txt',
246 'is_dir base file' => [
251 'is_dir Resources/content.txt' => [
253 $deniedPath .
'/Resources/content.txt',
256 'file_exists base file' => [
261 'file_exists Resources/content.txt' => [
263 $deniedPath .
'/Resources/content.txt',
279 self::expectException(Exception::class);
280 self::expectExceptionCode(1530103998);
282 $path = $this->instancePath .
'/' . $path;
283 call_user_func($functionName,
'phar://' . $path);
291 $allowedPath = $this->instancePath .
'/typo3conf/ext/test_resources/bundle.phar';
292 $handle = fopen(
'phar://' . $allowedPath .
'/Resources/content.txt',
'r');
293 self::assertInternalType(
'resource', $handle);
301 $allowedPath = $this->instancePath .
'/typo3conf/ext/test_resources/bundle.phar';
302 $handle = fopen(
'phar://' . $allowedPath .
'/Resources/content.txt',
'r');
303 $content = fread($handle, 1024);
304 self::assertSame(
'TYPO3 demo text file.', $content);
312 $allowedPath = $this->instancePath .
'/typo3conf/ext/test_resources/bundle.phar';
313 $handle = fopen(
'phar://' . $allowedPath .
'/Resources/content.txt',
'r');
314 fread($handle, 1024);
315 self::assertTrue(feof($handle));
323 $allowedPath = $this->instancePath .
'/typo3conf/ext/test_resources/bundle.phar';
324 $handle = fopen(
'phar://' . $allowedPath .
'/Resources/content.txt',
'r');
326 self::assertFalse(is_resource($handle));
334 $allowedPath = $this->instancePath .
'/typo3conf/ext/test_resources/bundle.phar';
335 $content = file_get_contents(
'phar://' . $allowedPath .
'/Resources/content.txt');
336 self::assertSame(
'TYPO3 demo text file.', $content);
344 $allowedPath = $this->instancePath .
'/typo3conf/ext/test_resources/bundle.phar';
345 include(
'phar://' . $allowedPath .
'/Classes/Domain/Model/DemoModel.php');
349 \TYPO3Demo\Demo\Domain\Model\DemoModel::class,
360 self::expectException(Exception::class);
361 self::expectExceptionCode(1530103998);
363 $allowedPath = $this->instancePath .
'/fileadmin/bundle.phar';
364 fopen(
'phar://' . $allowedPath .
'/Resources/content.txt',
'r');
372 self::expectException(Exception::class);
373 self::expectExceptionCode(1530103998);
375 $allowedPath = $this->instancePath .
'/fileadmin/bundle.phar';
376 file_get_contents(
'phar://' . $allowedPath .
'/Resources/content.txt');
384 self::expectException(Exception::class);
385 self::expectExceptionCode(1530103998);
387 $allowedPath = $this->instancePath .
'/fileadmin/bundle.phar';
388 include(
'phar://' . $allowedPath .
'/Classes/Domain/Model/DemoModel.php');