TYPO3 CMS  TYPO3_7-6
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 
21 {
25  protected $subject = null;
26 
32  protected function setUp()
33  {
34  $this->subject = new \TYPO3\CMS\Core\Imaging\GraphicalFunctions();
35  }
36 
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 
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 }
getScaleForImage($info, $width, $height, $options, $expected)