[BUGFIX] Add missing namespace parts
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Imaging / GraphicalFunctionsTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Imaging;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Testcase for \TYPO3\CMS\Core\Imaging\GraphicalFunctions
19 */
20 class GraphicalFunctionsTest extends \TYPO3\Components\TestingFramework\Core\Unit\UnitTestCase
21 {
22 /**
23 * @var \TYPO3\CMS\Core\Imaging\GraphicalFunctions
24 */
25 protected $subject = null;
26
27 /**
28 * Set up
29 *
30 * @return void
31 */
32 protected function setUp()
33 {
34 $this->subject = new \TYPO3\CMS\Core\Imaging\GraphicalFunctions();
35 }
36
37 /**
38 * Dataprovider for getScaleForImage
39 *
40 * @return array
41 */
42 public function getScaleForImageDataProvider()
43 {
44 return [
45 'Get image scale for a width of 150px' => [
46 [
47 170,
48 136,
49 ],
50 '150',
51 '',
52 [],
53 [
54 'crs' => false,
55 'origW' => 150,
56 'origH' => 0,
57 'max' => 0,
58 0 => 150,
59 1 => (float) 120
60 ],
61 ],
62 'Get image scale with a maximum width of 100px' => [
63 [
64 170,
65 136,
66 ],
67 '',
68 '',
69 [
70 'maxW' => 100
71 ],
72 [
73 'crs' => false,
74 'origW' => 100,
75 'origH' => 0,
76 'max' => 1,
77 0 => 100,
78 1 => (float) 80
79 ],
80 ],
81 'Get image scale with a minimum width of 200px' => [
82 [
83 170,
84 136,
85 ],
86 '',
87 '',
88 [
89 'minW' => 200
90 ],
91 [
92 'crs' => false,
93 'origW' => 0,
94 'origH' => 0,
95 'max' => 0,
96 0 => 200,
97 1 => (float) 136
98 ],
99 ],
100 ];
101 }
102
103 /**
104 * @test
105 * @dataProvider getScaleForImageDataProvider
106 */
107 public function getScaleForImage($info, $width, $height, $options, $expected)
108 {
109 $result = $this->subject->getImageScale($info, $width, $height, $options);
110 $this->assertEquals($result, $expected);
111 }
112 }