From 0c22f21a853d89145478e3749bb709cc2136037a Mon Sep 17 00:00:00 2001
From: Elmar Hinz <t3elmar@gmail.com>
Date: Wed, 15 Jun 2016 08:51:35 +0200
Subject: [PATCH] [TASK] Add unit test to cover stdWrap_setCurrent

Resolves: #76634
Releases: master
Change-Id: If532940407542d3c62edb98e23ffe1037a4eb43c
Reviewed-on: https://review.typo3.org/48581
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
---
 .../ContentObjectRendererTest.php             | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
index 7eef0b1b5fce..710533bdb8d9 100755
--- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
+++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
@@ -845,6 +845,65 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         $this->assertSame($content, $this->subject->getData('current'));
     }
 
+    /**
+     * Data provider for stdWrap_setCurrent
+     *
+     * @return array Order input, conf
+     */
+    public function stdWrap_setCurrentDataProvider()
+    {
+        return [
+            'no conf' => [
+                'content',
+                [],
+            ],
+            'empty string' => [
+                'content',
+                ['setCurrent' => ''],
+            ],
+            'non-empty string' => [
+                'content',
+                ['setCurrent' => 'xxx'],
+            ],
+            'integer null' => [
+                'content',
+                ['setCurrent' => 0],
+            ],
+            'integer not null' => [
+                'content',
+                ['setCurrent' => 1],
+            ],
+            'boolean true' => [
+                'content',
+                ['setCurrent' => true],
+            ],
+            'boolean false' => [
+                'content',
+                ['setCurrent' => false],
+            ],
+        ];
+    }
+
+    /**
+     * Check if stdWrap_setCurrent works properly.
+     *
+     * @test
+     * @dataProvider stdWrap_setCurrentDataProvider
+     * @param string $input The input value.
+     * @param array $conf Property: setCurrent
+     * @return void
+     */
+    public function stdWrap_setCurrent($input, $conf)
+    {
+        if (isset($conf['setCurrent'])) {
+            $this->assertNotSame($conf['setCurrent'], $this->subject->getData('current'));
+        }
+        $this->assertSame($input, $this->subject->stdWrap_setCurrent($input, $conf));
+        if (isset($conf['setCurrent'])) {
+            $this->assertSame($conf['setCurrent'], $this->subject->getData('current'));
+        }
+    }
+
     /**
      * Data provider for stdWrap_csConv
      *
-- 
GitLab