TYPO3 CMS  TYPO3_8-7
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 
20 
24 class GifBuilderTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
25 {
31  public function overlayImagesHasStableHash()
32  {
33  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/sys_file_storage.xml');
34  $this->setUpBackendUserFromFixture(1);
35 
36  copy(
37  PATH_site . 'typo3/sysext/frontend/Tests/Functional/Fixtures/Images/kasper-skarhoj1.jpg',
38  PATH_site . 'fileadmin/kasper-skarhoj1.jpg'
39  );
40 
41  $storageRepository = (new StorageRepository())->findByUid(1);
42  $file = $storageRepository->getFile('kasper-skarhoj1.jpg');
43 
44  $this->assertFalse($file->isMissing());
45 
46  $fileArray = [
47  'XY' => '[10.w],[10.h]',
48  'format' => 'jpg',
49  'quality' => 88,
50  '10' => 'IMAGE',
51  '10.' => [
52  'file.width' => 300,
53  'file' => $file,
54  ],
55  '30' => 'IMAGE',
56  '30.' => [
57  'file' => $file,
58  'file.' => [
59  'align' => 'l,t',
60  'width' => 100
61  ]
62  ]
63  ];
64 
65  $gifBuilder = new GifBuilder();
66  $gifBuilder->init();
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->init();
74  $gifBuilder->start($fileArray, []);
75  $setup2 = $gifBuilder->setup;
76  $fileName2 = $gifBuilder->gifBuild();
77 
78  $this->assertSame($setup1, $setup2, 'The Setup resulting from two equal configurations must be equal');
79  $this->assertSame($fileName1, $fileName2);
80  }
81 }