[TASK] Unit tests to cover stdWrap_preCObject, stdWrap_postCObject 46/48746/8
authorElmar Hinz <t3elmar@gmail.com>
Thu, 30 Jun 2016 09:46:50 +0000 (11:46 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Wed, 13 Jul 2016 18:31:18 +0000 (20:31 +0200)
- Add unit test to cover stdWrap_preCObject
- Add unit test to cover stdWrap_postCObject
- Refactor unit test to cover stdWrap_cObject

Releases: master
Resolves: #76834
Resolves: #76835
Resolves: #76735
Change-Id: I11612aee5b7b90a77e3ebab29059f2ea435521f9
Reviewed-on: https://review.typo3.org/48746
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index f221d0a..19ce265 100644 (file)
@@ -4791,10 +4791,10 @@ class ContentObjectRendererTest extends UnitTestCase
      * Show:
      *
      * - Delegates to the method cObjGetSingle().
-     * - First parameter is $conf['cObject'].
-     * - Second parameter is $conf['cObject.'].
-     * - Third parameter is '/stdWrap/.cObject'.
-     * - Returns the return.
+     * - Parameter 1 is $conf['cObject'].
+     * - Parameter 2 is $conf['cObject.'].
+     * - Parameter 3 is '/stdWrap/.cObject'.
+     * - Returns the return value.
      *
      * @test
      * @return void
@@ -4802,6 +4802,7 @@ class ContentObjectRendererTest extends UnitTestCase
     public function stdWrap_cObject()
     {
         $debugKey =  '/stdWrap/.cObject';
+        $content = $this->getUniqueId('content');
         $conf = [
             'cObject' => $this->getUniqueId('cObject'),
             'cObject.' => [$this->getUniqueId('cObject.')],
@@ -4815,7 +4816,7 @@ class ContentObjectRendererTest extends UnitTestCase
             ->with($conf['cObject'], $conf['cObject.'], $debugKey)
             ->willReturn($return);
         $this->assertSame($return,
-            $subject->stdWrap_cObject('discard', $conf));
+            $subject->stdWrap_cObject($content, $conf));
     }
 
     /**
@@ -6920,6 +6921,40 @@ class ContentObjectRendererTest extends UnitTestCase
     }
 
     /**
+     * Check if stdWrap_postCObject works properly.
+     *
+     * Show:
+     *
+     * - Delegates to the method cObjGetSingle().
+     * - Parameter 1 is $conf['postCObject'].
+     * - Parameter 2 is $conf['postCObject.'].
+     * - Parameter 3 is '/stdWrap/.postCObject'.
+     * - Returns the return value appended by $content.
+     *
+     * @test
+     * @return void
+     */
+    public function stdWrap_postCObject()
+    {
+        $debugKey =  '/stdWrap/.postCObject';
+        $content = $this->getUniqueId('content');
+        $conf = [
+            'postCObject' => $this->getUniqueId('postCObject'),
+            'postCObject.' => [$this->getUniqueId('postCObject.')],
+        ];
+        $return = $this->getUniqueId('return');
+        $subject = $this->getMockBuilder(ContentObjectRenderer::class)
+            ->setMethods(['cObjGetSingle'])->getMock();
+        $subject
+            ->expects($this->once())
+            ->method('cObjGetSingle')
+            ->with($conf['postCObject'], $conf['postCObject.'], $debugKey)
+            ->willReturn($return);
+        $this->assertSame($content . $return,
+            $subject->stdWrap_postCObject($content, $conf));
+    }
+
+    /**
      * Check that stdWrap_postUserFunc works properly.
      *
      * Show:
@@ -7001,6 +7036,40 @@ class ContentObjectRendererTest extends UnitTestCase
     }
 
     /**
+     * Check if stdWrap_preCObject works properly.
+     *
+     * Show:
+     *
+     * - Delegates to the method cObjGetSingle().
+     * - Parameter 1 is $conf['preCObject'].
+     * - Parameter 2 is $conf['preCObject.'].
+     * - Parameter 3 is '/stdWrap/.preCObject'.
+     * - Returns the return value appended by $content.
+     *
+     * @test
+     * @return void
+     */
+    public function stdWrap_preCObject()
+    {
+        $debugKey =  '/stdWrap/.preCObject';
+        $content = $this->getUniqueId('content');
+        $conf = [
+            'preCObject' => $this->getUniqueId('preCObject'),
+            'preCObject.' => [$this->getUniqueId('preCObject.')],
+        ];
+        $return = $this->getUniqueId('return');
+        $subject = $this->getMockBuilder(ContentObjectRenderer::class)
+            ->setMethods(['cObjGetSingle'])->getMock();
+        $subject
+            ->expects($this->once())
+            ->method('cObjGetSingle')
+            ->with($conf['preCObject'], $conf['preCObject.'], $debugKey)
+            ->willReturn($return);
+        $this->assertSame($return . $content,
+            $subject->stdWrap_preCObject($content, $conf));
+    }
+
+    /**
      * Check if stdWrap_preIfEmptyListNum works properly.
      *
      * Show: