[TASK] Add unit test to cover stdWrap_append 33/48733/4
authorElmar Hinz <t3elmar@gmail.com>
Wed, 29 Jun 2016 10:38:40 +0000 (12:38 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 6 Jul 2016 15:05:29 +0000 (17:05 +0200)
Releases: master
Resolves: #76846
Change-Id: Ia269a9d72b90235b0ee181604e868ea2c859dfec
Reviewed-on: https://review.typo3.org/48733
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 657e25b..39d4fd0 100644 (file)
@@ -1319,18 +1319,53 @@ class ContentObjectRendererTest extends UnitTestCase
             'cObject' => $this->getUniqueId('cObject'),
             'cObject.' => [$this->getUniqueId('cObject.')],
         ];
+        $return = $this->getUniqueId('return');
         $subject = $this->getMockBuilder(ContentObjectRenderer::class)
             ->setMethods(['cObjGetSingle'])->getMock();
         $subject
             ->expects($this->once())
             ->method('cObjGetSingle')
             ->with($conf['cObject'], $conf['cObject.'], $debugKey)
-            ->willReturn('return');
-        $this->assertSame('return',
+            ->willReturn($return);
+        $this->assertSame($return,
             $subject->stdWrap_cObject('discard', $conf));
     }
 
     /**
+     * Check if stdWrap_append works properly.
+     *
+     * Show:
+     *
+     * - Delegates to the method cObjGetSingle().
+     * - First parameter is $conf['append'].
+     * - Second parameter is $conf['append.'].
+     * - Third parameter is '/stdWrap/.append'.
+     * - Returns the return value appended to $content.
+     *
+     * @test
+     * @return void
+     */
+    public function stdWrap_append()
+    {
+        $debugKey =  '/stdWrap/.append';
+        $content = $this->getUniqueId('content');
+        $conf = [
+            'append' => $this->getUniqueId('append'),
+            'append.' => [$this->getUniqueId('append.')],
+        ];
+        $return = $this->getUniqueId('return');
+        $subject = $this->getMockBuilder(ContentObjectRenderer::class)
+            ->setMethods(['cObjGetSingle'])->getMock();
+        $subject
+            ->expects($this->once())
+            ->method('cObjGetSingle')
+            ->with($conf['append'], $conf['append.'], $debugKey)
+            ->willReturn($return);
+        $this->assertSame($content . $return,
+            $subject->stdWrap_append($content, $conf));
+    }
+
+    /**
      * Check if stdWrap_numRows works properly.
      *
      * Show: