TYPO3 CMS  TYPO3_8-7
ImageInfoTest.php
Go to the documentation of this file.
1 <?php
2 
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 
22 
26 class ImageInfoTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
27 {
28 
33  {
34  $className = \TYPO3\CMS\Core\Type\File\ImageInfo::class;
35  $classInstance = new \TYPO3\CMS\Core\Type\File\ImageInfo('FooFileName');
36  $this->assertInstanceOf($className, $classInstance);
37  }
38 
43  {
44  $root = vfsStream::setup('root');
45  $testFile = 'test.svg';
46  vfsStream::newFile($testFile)->at($root)->setContent('Invalid XML.');
47 
48  $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType'] = [
49  'svg' => 'image/svg+xml',
50  'youtube' => 'video/youtube',
51  'vimeo' => 'video/vimeo',
52  ];
53 
54  $graphicalFunctionsProphecy = $this->prophesize(GraphicalFunctions::class);
55  $graphicalFunctionsProphecy->init()->shouldBeCalled();
56  $graphicalFunctionsProphecy->imageMagickIdentify($root->url() . '/' . $testFile)->willReturn(null);
57  GeneralUtility::addInstance(GraphicalFunctions::class, $graphicalFunctionsProphecy->reveal());
58 
59  $imageInfo = new ImageInfo($root->url() . '/' . $testFile);
60 
61  $this->assertEquals(0, $imageInfo->getWidth());
62  $this->assertEquals(0, $imageInfo->getHeight());
63  }
64 
68  public function canDetectImageSizesDataProvider(): array
69  {
70  return [
71  'svg' => ['test.svg', 80, 80],
72  'jpg' => ['test.jpg', 600, 388],
73  'png' => ['test.png', 600, 388],
74  ];
75  }
76 
81  public function canDetectImageSizes($file, $width, $height)
82  {
83  $imageInfo = new ImageInfo(__DIR__ . '/../Fixture/' . $file);
84 
85  $this->assertEquals($width, $imageInfo->getWidth());
86  $this->assertEquals($height, $imageInfo->getHeight());
87  }
88 }
static addInstance($className, $instance)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']