‪TYPO3CMS  11.5
GifBuilderTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪GifBuilderTest extends UnitTestCase
27 {
28  protected ‪$resetSingletonInstances = true;
29 
31 
32  protected function ‪setUp(): void
33  {
34  parent::setUp();
35 
36  $this->subject = new ‪GifBuilder();
37  }
38 
42  public function singleIntegerDataProvider(): array
43  {
44  return [
45  'positive integer' => ['1'],
46  'negative integer' => ['-1'],
47  'zero' => ['0'],
48  ];
49  }
50 
57  {
58  $result = $this->subject->calcOffset($number);
59 
60  self::assertSame($number, $result);
61  }
62 
67  {
68  $numbers = '1,2,3';
69  $result = $this->subject->calcOffset($numbers);
70 
71  self::assertSame($numbers, $result);
72  }
73 
78  {
79  $result = $this->subject->calcOffset(' 1, 2, 3 ');
80 
81  self::assertSame('1,2,3', $result);
82  }
83 
87  public function roundingDataProvider(): array
88  {
89  return [
90  'rounding down' => ['1.1', '1'],
91  'rounding up' => ['1.9', '2'],
92  ];
93  }
94 
100  public function ‪calcOffsetRoundsNumbersToNearestInteger(string $input, string $expectedResult): void
101  {
102  $result = $this->subject->calcOffset($input);
103 
104  self::assertSame($expectedResult, $result);
105  }
106 
110  public function calculationDataProvider(): array
111  {
112  return [
113  'addition of positive numbers' => ['1+1', '2'],
114  'addition of negative numbers' => ['-1+-1', '-2'],
115  'subtraction' => ['5-2', '3'],
116  'multiplication' => ['2*5', '10'],
117  'division with whole-number result' => ['10/5', '2'],
118  'division with rounding up' => ['19/5', '4'],
119  'division with rounding down' => ['21/5', '4'],
120  'modulo' => ['21%5', '1'],
121  ];
122  }
123 
129  public function ‪calcOffsetDoesTheProvidedCalculation(string $input, string $expectedResult): void
130  {
131  $result = $this->subject->calcOffset($input);
132 
133  self::assertSame($expectedResult, $result);
134  }
135 }
‪TYPO3\CMS\Frontend\Tests\Unit\Imaging\GifBuilderTest\calcOffsetRoundsNumbersToNearestInteger
‪calcOffsetRoundsNumbersToNearestInteger(string $input, string $expectedResult)
Definition: GifBuilderTest.php:100
‪TYPO3\CMS\Frontend\Tests\Unit\Imaging\GifBuilderTest\calcOffsetDoesTheProvidedCalculation
‪calcOffsetDoesTheProvidedCalculation(string $input, string $expectedResult)
Definition: GifBuilderTest.php:129
‪TYPO3\CMS\Frontend\Tests\Unit\Imaging\GifBuilderTest
Definition: GifBuilderTest.php:27
‪TYPO3\CMS\Frontend\Tests\Unit\Imaging\GifBuilderTest\calcOffsetWithMultipleIntegersReturnsTheGivenIntegerCommaSeparated
‪calcOffsetWithMultipleIntegersReturnsTheGivenIntegerCommaSeparated()
Definition: GifBuilderTest.php:66
‪TYPO3\CMS\Frontend\Tests\Unit\Imaging\GifBuilderTest\setUp
‪setUp()
Definition: GifBuilderTest.php:32
‪TYPO3\CMS\Frontend\Tests\Unit\Imaging\GifBuilderTest\calcOffsetWithSingleIntegerReturnsTheGivenIntegerAsString
‪calcOffsetWithSingleIntegerReturnsTheGivenIntegerAsString(string $number)
Definition: GifBuilderTest.php:56
‪TYPO3\CMS\Frontend\Tests\Unit\Imaging\GifBuilderTest\$resetSingletonInstances
‪$resetSingletonInstances
Definition: GifBuilderTest.php:28
‪TYPO3\CMS\Frontend\Imaging\GifBuilder
Definition: GifBuilder.php:57
‪TYPO3\CMS\Frontend\Tests\Unit\Imaging
Definition: GifBuilderTest.php:18
‪TYPO3\CMS\Frontend\Tests\Unit\Imaging\GifBuilderTest\calcOffsetTrimsWhitespaceAroundProvidedNumbers
‪calcOffsetTrimsWhitespaceAroundProvidedNumbers()
Definition: GifBuilderTest.php:77
‪TYPO3\CMS\Frontend\Tests\Unit\Imaging\GifBuilderTest\$subject
‪GifBuilder $subject
Definition: GifBuilderTest.php:30