‪TYPO3CMS  9.5
GifBuilderTest.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 
21 
25 class ‪GifBuilderTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
26 {
33  {
34  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/sys_file_storage.xml');
35  $this->setUpBackendUserFromFixture(1);
36 
37  copy(
38  ‪Environment::getFrameworkBasePath() . '/frontend/Tests/Functional/Fixtures/Images/kasper-skarhoj1.jpg',
39  ‪Environment::getPublicPath() . '/fileadmin/kasper-skarhoj1.jpg'
40  );
41 
42  $storageRepository = (new ‪StorageRepository())->findByUid(1);
43  $file = $storageRepository->getFile('kasper-skarhoj1.jpg');
44 
45  $this->assertFalse($file->isMissing());
46 
47  $fileArray = [
48  'XY' => '[10.w],[10.h]',
49  'format' => 'jpg',
50  'quality' => 88,
51  '10' => 'IMAGE',
52  '10.' => [
53  'file.width' => 300,
54  'file' => $file,
55  ],
56  '30' => 'IMAGE',
57  '30.' => [
58  'file' => $file,
59  'file.' => [
60  'align' => 'l,t',
61  'width' => 100
62  ]
63  ]
64  ];
65 
66  $gifBuilder = new ‪GifBuilder();
67  $gifBuilder->start($fileArray, []);
68  $setup1 = $gifBuilder->setup;
69  $fileName1 = $gifBuilder->gifBuild();
70 
71  // Recreate a fresh GifBuilder instance, to catch inconsistencies in hashing for different instances
72  $gifBuilder = new ‪GifBuilder();
73  $gifBuilder->start($fileArray, []);
74  $setup2 = $gifBuilder->setup;
75  $fileName2 = $gifBuilder->gifBuild();
76 
77  $this->assertSame($setup1, $setup2, 'The Setup resulting from two equal configurations must be equal');
78  $this->assertSame($fileName1, $fileName2);
79  }
80 }
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:153
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\GifBuilderTest\overlayImagesHasStableHash
‪overlayImagesHasStableHash()
Definition: GifBuilderTest.php:32
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\GifBuilderTest
Definition: GifBuilderTest.php:26
‪TYPO3\CMS\Core\Core\Environment\getFrameworkBasePath
‪static string getFrameworkBasePath()
Definition: Environment.php:234
‪TYPO3\CMS\Core\Resource\StorageRepository
Definition: StorageRepository.php:29
‪TYPO3\CMS\Frontend\Imaging\GifBuilder
Definition: GifBuilder.php:52
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject
Definition: ContentObjectRendererTest.php:2