‪TYPO3CMS  11.5
GifBuilderTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
26 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
27 
31 class ‪GifBuilderTest extends FunctionalTestCase
32 {
38  public function ‪overlayImagesHasStableHash(): void
39  {
40  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/sys_file_storage.xml');
41  $this->setUpBackendUserFromFixture(1);
42 
43  ‪$GLOBALS['TYPO3_REQUEST'] = (new ‪ServerRequest('https://www.example.com/'))
44  ->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_BE);
45 
46  copy(
47  __DIR__ . '/../Fixtures/Images/kasper-skarhoj1.jpg',
48  ‪Environment::getPublicPath() . '/fileadmin/kasper-skarhoj1.jpg'
49  );
50 
51  $storageRepository = GeneralUtility::makeInstance(StorageRepository::class)->findByUid(1);
52  $file = $storageRepository->getFile('kasper-skarhoj1.jpg');
53 
54  self::assertFalse($file->isMissing());
55 
56  $fileArray = [
57  'XY' => '[10.w],[10.h]',
58  'format' => 'jpg',
59  'quality' => 88,
60  '10' => 'IMAGE',
61  '10.' => [
62  'file.width' => 300,
63  'file' => $file,
64  ],
65  '30' => 'IMAGE',
66  '30.' => [
67  'file' => $file,
68  'file.' => [
69  'align' => 'l,t',
70  'width' => 100,
71  ],
72  ],
73  ];
74 
75  $gifBuilder = new ‪GifBuilder();
76  $gifBuilder->start($fileArray, []);
77  $setup1 = $gifBuilder->setup;
78  $fileName1 = $gifBuilder->gifBuild();
79 
80  // Recreate a fresh GifBuilder instance, to catch inconsistencies in hashing for different instances
81  $gifBuilder = new ‪GifBuilder();
82  $gifBuilder->start($fileArray, []);
83  $setup2 = $gifBuilder->setup;
84  $fileName2 = $gifBuilder->gifBuild();
85 
86  self::assertSame($setup1, $setup2, 'The Setup resulting from two equal configurations must be equal');
87  self::assertSame($fileName1, $fileName2);
88  }
89 }
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:206
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_BE
‪const REQUESTTYPE_BE
Definition: SystemEnvironmentBuilder.php:45
‪TYPO3\CMS\Frontend\Tests\Functional\Imaging
Definition: GifBuilderTest.php:18
‪TYPO3\CMS\Core\Resource\StorageRepository
Definition: StorageRepository.php:38
‪TYPO3\CMS\Frontend\Tests\Functional\Imaging\GifBuilderTest\overlayImagesHasStableHash
‪overlayImagesHasStableHash()
Definition: GifBuilderTest.php:38
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:37
‪TYPO3\CMS\Frontend\Imaging\GifBuilder
Definition: GifBuilder.php:57
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Frontend\Tests\Functional\Imaging\GifBuilderTest
Definition: GifBuilderTest.php:32
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:43
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50