[TASK] Add unit test to cover stdWrap_wrapAlign 22/48822/5
authorElmar Hinz <t3elmar@gmail.com>
Wed, 6 Jul 2016 10:21:01 +0000 (12:21 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Thu, 7 Jul 2016 19:16:28 +0000 (21:16 +0200)
Releases: master
Resolves: #76836
Change-Id: I7e805b0850a47f5e6040c5b56fdb1a3c190ede07
Reviewed-on: https://review.typo3.org/48822
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 6718a00..92f2bdb 100644 (file)
@@ -7664,6 +7664,52 @@ class ContentObjectRendererTest extends UnitTestCase
         $this->assertSame($expected, $this->subject->stdWrap_wrap3($input, $conf));
     }
 
+    /**
+     * Data provider for stdWrap_wrapAlign.
+     *
+     * @return array [$expect, $content, $conf]
+     */
+    public function stdWrap_wrapAlignDataProvider()
+    {
+        $format = '<div style="text-align:%s;">%s</div>';
+        $content = $this->getUniqueId('content');
+        $wrapAlign = $this->getUniqueId('wrapAlign');
+        $expect = sprintf($format, $wrapAlign, $content);
+        return [
+            'standard case' => [$expect, $content, $wrapAlign],
+            'empty conf' => [$content, $content, null],
+            'empty string' => [$content, $content, ''],
+            'whitespaced zero string' => [$content, $content, ' 0 '],
+        ];
+    }
+
+    /**
+     * Check if stdWrap_wrapAlign works properly.
+     *
+     * Show:
+     *
+     * - Wraps $content with div and style attribute.
+     * - The style attribute is taken from $conf['wrapAlign'].
+     * - Returns the content as is,
+     * - if $conf['wrapAlign'] evals to false after being trimmed.
+     *
+     * @test
+     * @dataProvider stdWrap_wrapAlignDataProvider
+     * @param string $expect The expected output.
+     * @param string $content The given content.
+     * @param mixed $wrapAlignConf The given input.
+     * @return void
+     */
+    public function stdWrap_wrapAlign($expect, $content, $wrapAlignConf)
+    {
+        $conf = [];
+        if ($wrapAlignConf !== null) {
+            $conf['wrapAlign'] = $wrapAlignConf;
+        }
+        $this->assertSame($expect,
+            $this->subject->stdWrap_wrapAlign($content, $conf));
+    }
+
   /***************************************************************************
    * End of tests of stdWrap
    ***************************************************************************/