[TASK] Add unit tests for ImageInfo 95/56895/3
authorAnja Leichsenring <anja.leichsenring@typo3.com>
Sun, 6 May 2018 07:33:09 +0000 (09:33 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Wed, 9 May 2018 11:24:12 +0000 (13:24 +0200)
Change-Id: I3d9ef96e3296de676d02aa84a5ebd926b10cae53
Resolves: #84934
Relates: #84583
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/56895
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/core/Tests/Unit/Type/File/ImageInfoTest.php
typo3/sysext/core/Tests/Unit/Type/Fixture/test.jpg [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Type/Fixture/test.png [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Type/Fixture/test.svg [new file with mode: 0644]

index 84bbbfd..ba04ccd 100644 (file)
@@ -61,4 +61,28 @@ class ImageInfoTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->assertEquals(0, $imageInfo->getWidth());
         $this->assertEquals(0, $imageInfo->getHeight());
     }
+
+    /**
+     * @return array
+     */
+    public function canDetectImageSizesDataProvider(): array
+    {
+        return [
+            'svg' => ['test.svg', 80, 80],
+            'jpg' => ['test.jpg', 600, 388],
+            'png' => ['test.png', 600, 388],
+        ];
+    }
+
+    /**
+     * @test
+     * @dataProvider canDetectImageSizesDataProvider
+     */
+    public function canDetectImageSizes($file, $width, $height)
+    {
+        $imageInfo = new ImageInfo(__DIR__ . '/../Fixture/' . $file);
+
+        $this->assertEquals($width, $imageInfo->getWidth());
+        $this->assertEquals($height, $imageInfo->getHeight());
+    }
 }
diff --git a/typo3/sysext/core/Tests/Unit/Type/Fixture/test.jpg b/typo3/sysext/core/Tests/Unit/Type/Fixture/test.jpg
new file mode 100644 (file)
index 0000000..937f288
Binary files /dev/null and b/typo3/sysext/core/Tests/Unit/Type/Fixture/test.jpg differ
diff --git a/typo3/sysext/core/Tests/Unit/Type/Fixture/test.png b/typo3/sysext/core/Tests/Unit/Type/Fixture/test.png
new file mode 100644 (file)
index 0000000..2328299
Binary files /dev/null and b/typo3/sysext/core/Tests/Unit/Type/Fixture/test.png differ
diff --git a/typo3/sysext/core/Tests/Unit/Type/Fixture/test.svg b/typo3/sysext/core/Tests/Unit/Type/Fixture/test.svg
new file mode 100644 (file)
index 0000000..434a3fd
--- /dev/null
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80"><style>.fillColor{fill: #ff8800;}</style><switch><g><path class="fillColor" d="M57.288 52.902c-1.031.344-1.892.344-2.923.344-8.602 0-21.504-30.276-21.504-40.426 0-3.785.86-4.989 2.063-6.021C24.261 8.002 11.529 11.96 7.4 16.949c-.688 1.203-1.203 3.095-1.203 5.675 0 15.829 16.856 51.608 28.728 51.608 5.505-.17 14.622-9.115 22.363-21.33M51.785 5.768c11.009 0 22.018 1.72 22.018 7.913 0 12.558-7.913 27.867-12.042 27.867-7.224 0-16.343-20.125-16.343-30.276 0-4.644 1.72-5.504 6.367-5.504"/></g></switch></svg>
\ No newline at end of file