0f148e7068f47702f36debfc21666f9461a099db
[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 * @author Wouter Wolters <typo3@wouterwolters.nl>
21 */
22 class GraphicalFunctionsTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
23
24 /**
25 * @var \TYPO3\CMS\Core\Imaging\GraphicalFunctions
26 */
27 protected $fixture = NULL;
28
29 /**
30 * Set up
31 *
32 * @return void
33 */
34 protected function setUp() {
35 $this->fixture = new \TYPO3\CMS\Core\Imaging\GraphicalFunctions();
36 }
37
38 /**
39 * Dataprovider for getScaleForImage
40 *
41 * @return array
42 */
43 public function getScaleForImageDataProvider() {
44 return array(
45 'Get image scale for a width of 150px' => array(
46 array(
47 170,
48 136,
49 ),
50 '150',
51 '',
52 array(),
53 array(
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' => array(
63 array(
64 170,
65 136,
66 ),
67 '',
68 '',
69 array(
70 'maxW' => 100
71 ),
72 array(
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' => array(
82 array(
83 170,
84 136,
85 ),
86 '',
87 '',
88 array(
89 'minW' => 200
90 ),
91 array(
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 $result = $this->fixture->getImageScale($info, $width, $height, $options);
109 $this->assertEquals($result, $expected);
110 }
111
112 }