[TASK] Cover trivial setters and getters of cObj with unit tests 58/52258/7
authorElmar Hinz <t3elmar@gmail.com>
Thu, 30 Mar 2017 12:22:37 +0000 (14:22 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 14 Apr 2017 09:23:49 +0000 (11:23 +0200)
Cover trivial setters and getters of ContentObjectRenderer with
unit tests.

Releases: master
Resolves: #80574
Change-Id: Ibcad1c1d7166ad4f51eabd092a0b1301291c4875
Reviewed-on: https://review.typo3.org/52258
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 2ef11d5..f49683f 100644 (file)
@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Core\ApplicationContext;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
+use TYPO3\CMS\Core\Resource\ResourceStorage;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\DebugUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -7501,6 +7502,16 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTe
      ***************************************************************************/
 
     /**
+     * Check if getCurrentTable works properly.
+     *
+     * @test
+     */
+    public function getCurrentTable()
+    {
+        $this->assertEquals('tt_content', $this->subject->getCurrentTable());
+    }
+
+    /**
      * Data provider for linkWrap
      *
      * @return array [[$expected, $content, $wrap],]
@@ -7627,6 +7638,50 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTe
         $this->assertEquals($expect, $result);
     }
 
+    /**
+     * Check setter and getter of currentFile work properly.
+     *
+     * @test
+     */
+    public function setCurrentFile_getCurrentFile()
+    {
+        $storageMock = $this->createMock(ResourceStorage::class);
+        $file = new File(['testfile'], $storageMock);
+        $this->subject->setCurrentFile($file);
+        $this->assertSame($file, $this->subject->getCurrentFile());
+    }
+
+    /**
+     * Check setter and getter of currentVal work properly.
+     *
+     * Show it stored to $this->data[$this->currentValKey].
+     * (The default value of currentValKey is tested elsewhere.)
+     *
+     * @test
+     * @see $this->stdWrap_current()
+     */
+    public function setCurrentVal_getCurrentVal()
+    {
+        $key = $this->getUniqueId();
+        $value = $this->getUniqueId();
+        $this->subject->currentValKey = $key;
+        $this->subject->setCurrentVal($value);
+        $this->assertEquals($value, $this->subject->getCurrentVal());
+        $this->assertEquals($value, $this->subject->data[$key]);
+    }
+
+    /**
+     * Check setter and getter of userObjectType work properly.
+     *
+     * @test
+     */
+    public function setUserObjectType_getUserObjectType()
+    {
+        $value = $this->getUniqueId();
+        $this->subject->setUserObjectType($value);
+        $this->assertEquals($value, $this->subject->getUserObjectType());
+    }
+
     /***************************************************************************
      * End: Mixed tests
      ***************************************************************************/