[TASK] Shorten the extend class in all unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Imaging / IconProvider / FontawesomeIconProviderTest.php
index 6825c44..fa4e680 100644 (file)
@@ -16,47 +16,70 @@ namespace TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider;
 
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Testcase for \TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider
  */
-class FontawesomeIconProviderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
-
-       /**
-        * @var \TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider
-        */
-       protected $subject = NULL;
-
-       /**
-        * @var Icon
-        */
-       protected $icon = NULL;
-
-       /**
-        * Set up
-        *
-        * @return void
-        */
-       protected function setUp() {
-               $this->subject = new \TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider();
-               $this->icon = GeneralUtility::makeInstance(Icon::class);
-               $this->icon->setIdentifier('foo');
-               $this->icon->setSize(Icon::SIZE_SMALL);
-       }
-
-       /**
-        * @test
-        */
-       public function prepareIconMarkupWithNameReturnsInstanceOfIconWithCorrectMarkup() {
-               $this->subject->prepareIconMarkup($this->icon, array('name' => 'times'));
-               $this->assertEquals('<span class="icon-unify"><i class="fa fa-times"></i></span>', $this->icon->getMarkup());
-       }
-
-       /**
-        * @test
-        */
-       public function prepareIconMarkupWithNameAndAdditionalClassesReturnsInstanceOfIconWithCorrectMarkup() {
-               $this->subject->prepareIconMarkup($this->icon, array('name' => 'times', 'additionalClasses' => 'foo'));
-               $this->assertEquals('<span class="icon-unify"><i class="fa fa-times foo"></i></span>', $this->icon->getMarkup());
-       }
+class FontawesomeIconProviderTest extends UnitTestCase
+{
+    /**
+     * @var \TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider
+     */
+    protected $subject;
+
+    /**
+     * @var Icon
+     */
+    protected $icon;
+
+    /**
+     * Set up
+     */
+    protected function setUp()
+    {
+        $this->subject = new \TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider();
+        $this->icon = GeneralUtility::makeInstance(Icon::class);
+        $this->icon->setIdentifier('foo');
+        $this->icon->setSize(Icon::SIZE_SMALL);
+    }
+
+    /**
+     * @test
+     */
+    public function prepareIconMarkupWithNameReturnsInstanceOfIconWithCorrectMarkup()
+    {
+        $this->subject->prepareIconMarkup($this->icon, ['name' => 'times']);
+        $this->assertEquals('<span class="icon-unify"><i class="fa fa-times"></i></span>', $this->icon->getMarkup());
+    }
+
+    /**
+     * DataProvider for icon names
+     *
+     * @return array
+     */
+    public function wrongNamesDataProvider()
+    {
+        return [
+            'name with spaces' => ['name with spaces', 1440754979],
+            'name with spaces and umlauts' => ['name with spaces äöü', 1440754979],
+            'name umlauts' => ['häuser', 1440754979],
+            'name with underscore' => ['name_with_underscore', 1440754979],
+            'name is empty' => ['', 1440754978],
+        ];
+    }
+
+    /**
+     * @dataProvider wrongNamesDataProvider
+     * @param string $name
+     * @param int $expectedExceptionCode
+     * @test
+     */
+    public function prepareIconMarkupWithInvalidNameThrowsException($name, $expectedExceptionCode)
+    {
+        $this->expectException(\InvalidArgumentException::class);
+        $this->expectExceptionCode($expectedExceptionCode);
+
+        $this->subject->prepareIconMarkup($this->icon, ['name' => $name]);
+    }
 }