‪TYPO3CMS  ‪main
GraphicalFunctionsTest.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 
20 use PHPUnit\Framework\Attributes\Test;
21 use TYPO3\CMS\Core\Imaging\GraphicalFunctions;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
24 final class ‪GraphicalFunctionsTest extends UnitTestCase
25 {
26  protected bool ‪$resetSingletonInstances = true;
27 
28  #[Test]
30  {
31  $file = 'myImageFile.png';
32  $expected = [
33  '123',
34  '234',
35  'png',
36  'myImageFile.png',
37  'png',
38  ];
39 
40  $subject = $this->getAccessibleMock(GraphicalFunctions::class, ['executeIdentifyCommandForImageFile'], [], '', false);
41  $subject->_set('processorEnabled', true);
42  $subject->expects(self::once())->method('executeIdentifyCommandForImageFile')->with($file)->willReturn('123 234 png PNG');
43  $result = $subject->imageMagickIdentify($file);
44  self::assertEquals($result, $expected);
45  }
46 
47  #[Test]
49  {
50  $file = 'myImageFile.png';
51  $expected = [
52  '200+0+0',
53  '400+0+0',
54  'png',
55  'myImageFile.png',
56  'png',
57  ];
58 
59  $subject = $this->getAccessibleMock(GraphicalFunctions::class, ['executeIdentifyCommandForImageFile'], [], '', false);
60  $subject->_set('processorEnabled', true);
61  $subject->expects(self::once())->method('executeIdentifyCommandForImageFile')->with($file)->willReturn('200+0+0 400+0+0 png PNG');
62  $result = $subject->imageMagickIdentify($file);
63  self::assertEquals($result, $expected);
64  }
65 }
‪TYPO3\CMS\Core\Tests\Unit\Imaging\GraphicalFunctionsTest\imageMagickIdentifyReturnsFormattedValues
‪imageMagickIdentifyReturnsFormattedValues()
Definition: GraphicalFunctionsTest.php:29
‪TYPO3\CMS\Core\Tests\Unit\Imaging\GraphicalFunctionsTest\imageMagickIdentifyReturnsFormattedValuesWithOffset
‪imageMagickIdentifyReturnsFormattedValuesWithOffset()
Definition: GraphicalFunctionsTest.php:48
‪TYPO3\CMS\Core\Tests\Unit\Imaging\GraphicalFunctionsTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: GraphicalFunctionsTest.php:26
‪TYPO3\CMS\Core\Tests\Unit\Imaging
Definition: DimensionTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Imaging\GraphicalFunctionsTest
Definition: GraphicalFunctionsTest.php:25