TYPO3 CMS  TYPO3_8-7
GraphicalFunctionsTest.php
Go to the documentation of this file.
1 <?php
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 
20 class GraphicalFunctionsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
21 {
25  protected $subject = null;
26 
30  protected function setUp()
31  {
32  $this->subject = new \TYPO3\CMS\Core\Imaging\GraphicalFunctions();
33  }
34 
40  public function getScaleForImageDataProvider()
41  {
42  return [
43  'Get image scale for a width of 150px' => [
44  [
45  170,
46  136,
47  ],
48  '150',
49  '',
50  [],
51  [
52  'crs' => false,
53  'origW' => 150,
54  'origH' => 0,
55  'max' => 0,
56  0 => 150,
57  1 => (float)120
58  ],
59  ],
60  'Get image scale with a maximum width of 100px' => [
61  [
62  170,
63  136,
64  ],
65  '',
66  '',
67  [
68  'maxW' => 100
69  ],
70  [
71  'crs' => false,
72  'origW' => 100,
73  'origH' => 0,
74  'max' => 1,
75  0 => 100,
76  1 => (float)80
77  ],
78  ],
79  'Get image scale with a minimum width of 200px' => [
80  [
81  170,
82  136,
83  ],
84  '',
85  '',
86  [
87  'minW' => 200
88  ],
89  [
90  'crs' => false,
91  'origW' => 0,
92  'origH' => 0,
93  'max' => 0,
94  0 => 200,
95  1 => (float)136
96  ],
97  ],
98  'No PHP warning for zero in input dimensions when scaling' => [
99  [0, 0],
100  '50',
101  '',
102  [],
103  [
104  'crs' => false,
105  'origW' => 50,
106  'origH' => 0,
107  'max' => 0,
108  0 => 0,
109  1 => 0
110  ],
111  ],
112  ];
113  }
114 
119  public function getScaleForImage($info, $width, $height, $options, $expected)
120  {
121  $result = $this->subject->getImageScale($info, $width, $height, $options);
122  $this->assertEquals($result, $expected);
123  }
124 }
getScaleForImage($info, $width, $height, $options, $expected)