[TASK] Add unit test to cover stdWrap_postUnserFuncInt 26/48826/11
authorElmar Hinz <t3elmar@gmail.com>
Wed, 6 Jul 2016 11:48:47 +0000 (13:48 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 10 Jul 2016 18:40:23 +0000 (20:40 +0200)
Releases: master
Resolves: #76850
Change-Id: I80bbae8102b237d7368d6ed63ae4bde99c4e9b3f
Reviewed-on: https://review.typo3.org/48826
Tested-by: Bamboo TYPO3com <info@typo3.com>
Tested-by: Claus Due <claus@phpmind.net>
Tested-by: Ivaylo Ivanov <ivaylo.ivanov@dkd.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 214ad8b..5bbfde2 100644 (file)
@@ -6795,6 +6795,56 @@ class ContentObjectRendererTest extends UnitTestCase
     }
 
     /**
+     * Check if stdWrap_postUserFuncInt works properly.
+     *
+     * Show:
+     *
+     * - Calls frontend controller method uniqueHash.
+     * - Concatenates "INT_SCRIPT." and the returned hash to $substKey.
+     * - Configures the frontend controller for 'INTincScript.$substKey'.
+     * - The configuration array contains:
+     *   - content: $content
+     *   - postUserFunc: $conf['postUserFuncInt']
+     *   - conf: $conf['postUserFuncInt.']
+     *   - type: 'POSTUSERFUNC'
+     *   - cObj: serialized content renderer object
+     * - Returns "<!-- $substKey -->".
+     *
+     * @test
+     * @return void
+     */
+    public function stdWrap_postUserFuncInt()
+    {
+        $uniqueHash = $this->getUniqueId('uniqueHash');
+        $substKey = 'INT_SCRIPT.' . $uniqueHash;
+        $content = $this->getUniqueId('content');
+        $conf = [
+            'postUserFuncInt' => $this->getUniqueId('function'),
+            'postUserFuncInt.' => [$this->getUniqueId('function array')],
+        ];
+        $expect = '<!--' . $substKey . '-->';
+        $frontend = $this->getMockBuilder(TypoScriptFrontendController::class)
+            ->disableOriginalConstructor()->setMethods(['uniqueHash'])
+            ->getMock();
+        $frontend->expects($this->once())->method('uniqueHash')
+            ->with()->willReturn($uniqueHash);
+        $frontend->config = [];
+        $subject = $this->getAccessibleMock(
+            ContentObjectRenderer::class, null, [$frontend]);
+        $this->assertSame($expect,
+            $subject->stdWrap_postUserFuncInt($content, $conf));
+        $array = [
+            'content' => $content,
+            'postUserFunc' => $conf['postUserFuncInt'],
+            'conf' => $conf['postUserFuncInt.'],
+            'type' => 'POSTUSERFUNC',
+            'cObj' => serialize($subject)
+        ];
+        $this->assertSame($array,
+            $frontend->config['INTincScript'][$substKey]);
+    }
+
+    /**
      * Check if stdWrap_preIfEmptyListNum works properly.
      *
      * Show: