2 namespace TYPO3\CMS\Frontend\Tests\Unit\Processor;
17 use TYPO3\CMS\Core\Tests\UnitTestCase;
36 $this->contentObjectRenderer = $this->getMock(
37 ContentObjectRenderer::class,
50 $this->contentObjectRenderer,
63 'Default: horizontal above' => [
66 'horizontal' =>
'center',
67 'vertical' =>
'above',
72 [
'mediaOrientation' => 1],
74 'horizontal' =>
'right',
75 'vertical' =>
'above',
80 [
'mediaOrientation' => 2],
82 'horizontal' =>
'left',
83 'vertical' =>
'above',
88 [
'mediaOrientation' => 8],
90 'horizontal' =>
'center',
91 'vertical' =>
'below',
96 [
'mediaOrientation' => 9],
98 'horizontal' =>
'right',
99 'vertical' =>
'below',
104 [
'mediaOrientation' => 10],
106 'horizontal' =>
'left',
107 'vertical' =>
'below',
112 [
'mediaOrientation' => 17],
114 'horizontal' =>
'right',
115 'vertical' =>
'intext',
120 [
'mediaOrientation' => 18],
122 'horizontal' =>
'left',
123 'vertical' =>
'intext',
127 'right intext no wrap' => [
128 [
'mediaOrientation' => 25],
130 'horizontal' =>
'right',
131 'vertical' =>
'intext',
135 'left intext no wrap' => [
136 [
'mediaOrientation' => 26],
138 'horizontal' =>
'left',
139 'vertical' =>
'intext',
154 $processedData = $processor->process(
155 $this->contentObjectRenderer,
157 $processorConfiguration,
161 $this->assertEquals($expected, $processedData[
'gallery'][
'position']);
170 $processedData = $processor->process(
171 $this->contentObjectRenderer,
173 [
'maxGalleryWidth' => 200,
'maxGalleryWidthInText' => 100],
177 $this->assertEquals(200, $processedData[
'gallery'][
'width']);
186 $processedData = $processor->process(
187 $this->contentObjectRenderer,
189 [
'maxGalleryWidth' => 200,
'maxGalleryWidthInText' => 100,
'mediaOrientation' => 26],
193 $this->assertEquals(100, $processedData[
'gallery'][
'width']);
203 'Default settings with 3 files' => [
213 'NumberOfColumns set by value' => [
216 [
'numberOfColumns' => 2],
223 'NumberOfColumns set in data' => [
233 'NumberOfColumns set in custom data field' => [
235 [
'my_imagecols' => 4],
236 [
'numberOfColumns.' => [
237 'field' =>
'my_imagecols'
252 public function countResultTest($numberOfFiles, $data, $processorConfiguration, $expected)
255 for ($i = 0; $i < $numberOfFiles; $i++) {
256 $files[] = $this->getMock(FileReference::class, array(), array(),
'',
false);
258 $this->contentObjectRenderer->data = $data;
260 $processedData = $processor->process(
261 $this->contentObjectRenderer,
263 $processorConfiguration,
267 $this->assertEquals($expected, $processedData[
'gallery'][
'count']);
278 'Default settings' => [
287 1 => [
'width' => 200,
'height' => 100]
290 1 => [
'width' => 200,
'height' => 100]
293 1 => [
'width' => 200,
'height' => 100]
297 'Max width set + number of columns set' => [
303 [
'maxGalleryWidth' => 200,
'numberOfColumns' => 2],
306 1 => [
'width' => 100,
'height' => 50],
307 2 => [
'width' => 100,
'height' => 50]
310 1 => [
'width' => 100,
'height' => 50],
311 2 => [
'width' => null,
'height' => null]
315 'Max width set, number of columns + border (padding) set' => [
322 'maxGalleryWidth' => 200,
323 'numberOfColumns' => 2,
324 'borderEnabled' =>
true,
325 'borderPadding' => 4,
330 1 => [
'width' => 92,
'height' => 46],
331 2 => [
'width' => 92,
'height' => 46]
334 1 => [
'width' => 92,
'height' => 46],
335 2 => [
'width' => null,
'height' => null]
339 'Max width set, number of columns + border (width) set' => [
346 'maxGalleryWidth' => 200,
347 'numberOfColumns' => 2,
348 'borderEnabled' =>
true,
349 'borderPadding' => 0,
354 1 => [
'width' => 92,
'height' => 46],
355 2 => [
'width' => 92,
'height' => 46]
358 1 => [
'width' => 92,
'height' => 46],
359 2 => [
'width' => null,
'height' => null]
363 'Max width set, number of columns + border (padding + width) set' => [
370 'maxGalleryWidth' => 200,
371 'numberOfColumns' => 2,
372 'borderEnabled' =>
true,
373 'borderPadding' => 1,
378 1 => [
'width' => 90,
'height' => 45],
379 2 => [
'width' => 90,
'height' => 45]
382 1 => [
'width' => 90,
'height' => 45],
383 2 => [
'width' => null,
'height' => null]
387 'Equal height set' => [
396 'maxGalleryWidth' => 500,
397 'numberOfColumns' => 3,
398 'equalMediaHeight' => 75
402 1 => [
'width' => 150,
'height' => 75],
403 2 => [
'width' => 50,
'height' => 75],
404 3 => [
'width' => 150,
'height' => 75]
407 1 => [
'width' => 151,
'height' => 75],
408 2 => [
'width' => 75,
'height' => 75],
409 3 => [
'width' => null,
'height' => null]
413 'Equal width set' => [
420 'maxGalleryWidth' => 200,
421 'numberOfColumns' => 3,
422 'equalMediaWidth' => 75
426 1 => [
'width' => 66,
'height' => 33],
427 2 => [
'width' => 66,
'height' => 99],
428 3 => [
'width' => 66,
'height' => 33]
442 foreach ($testFiles as $fileConfig) {
443 $fileReference = $this->getMock(FileReference::class, array(), array(),
'',
false);
444 $fileReference->expects($this->any())
445 ->method(
'getProperty')
446 ->will($this->returnValueMap([
447 [
'width', $fileConfig[0]],
448 [
'height', $fileConfig[1]]
450 $files[] = $fileReference;
454 $processedData = $processor->process(
455 $this->contentObjectRenderer,
457 $processorConfiguration,
461 foreach ($expected as $row => $columns) {
462 $this->assertArrayHasKey($row, $processedData[
'gallery'][
'rows'],
'Row exists');
463 foreach ($columns as $column => $dimensions) {
464 $this->assertArrayHasKey($column, $processedData[
'gallery'][
'rows'][$row][
'columns'],
'Column exists');
465 $this->assertEquals($dimensions, $processedData[
'gallery'][
'rows'][$row][
'columns'][$column][
'dimensions'],
'Dimensions match');