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