[TASK] Write unit tests for stdWrap_ifEmpty() 82/43582/3
authorMichael Oehlhof <typo3@oehlhof.de>
Sat, 26 Sep 2015 17:29:37 +0000 (19:29 +0200)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Sun, 27 Sep 2015 12:13:33 +0000 (14:13 +0200)
Write unit tests for ContentObjectRenderer->stdWrap_ifEmpty()

Resolves: #70128
Releases: master
Change-Id: I4bafd4cf162a16fe6550a5b4a8d29d065b202cc3
Reviewed-on: http://review.typo3.org/43582
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 8206c3c..c0da47f 100644 (file)
@@ -6123,7 +6123,7 @@ class ContentObjectRenderer {
         * Basically the input string, $linktext, is (typically) wrapped in a <a>-tag linking to some page, email address, file or URL based on a parameter defined by the configuration array $conf.
         * This function is best used from internal functions as is. There are some API functions defined after this function which is more suited for general usage in external applications.
         * Generally the concept "typolink" should be used in your own applications as an API for making links to pages with parameters and more. The reason for this is that you will then automatically make links compatible with all the centralized functions for URL simulation and manipulation of parameters into hashes and more.
-        * For many more details on the parameters and how they are intepreted, please see the link to TSref below.
+        * For many more details on the parameters and how they are interpreted, please see the link to TSref below.
         *
         * the FAL API is handled with the namespace/prefix "file:..."
         *
index d2f85dd..4b0161e 100644 (file)
@@ -112,9 +112,9 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                parent::tearDown();
        }
 
-       ////////////////////////
-       // Utitility functions
-       ////////////////////////
+       //////////////////////
+       // Utility functions
+       //////////////////////
 
        /**
         * Avoid logging to the file system (file writer is currently the only configured writer)
@@ -184,9 +184,9 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
 
-       /*************************
-        * Tests concerning getContentObject
-        ************************/
+       //////////////////////////////////////
+       // Tests concerning getContentObject
+       //////////////////////////////////////
 
        public function getContentObjectValidContentObjectsDataProvider() {
                $dataProvider = array();
@@ -435,9 +435,9 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                return str_replace(array('[', ']'), array('%5B', '%5D'), $string);
        }
 
-       //////////////////////////////
+       //////////////////////////
        // Tests concerning crop
-       //////////////////////////////
+       //////////////////////////
        /**
         * @test
         */
@@ -1618,6 +1618,56 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        /**
+        * Data provider for stdWrap_ifEmptyDeterminesEmptyValues test
+        *
+        * @return array
+        */
+       public function stdWrap_ifEmptyDeterminesEmptyValuesDataProvider() {
+               return array(
+                       'null value' => array(
+                               NULL,
+                               array(
+                                       'ifEmpty' => '1',
+                               ),
+                               '1',
+                       ),
+                       'empty value' => array(
+                               '',
+                               array(
+                                       'ifEmpty' => '1',
+                               ),
+                               '1',
+                       ),
+                       'string value' => array(
+                               'string',
+                               array(
+                                       'ifEmpty' => '1',
+                               ),
+                               'string',
+                       ),
+                       'empty string value' => array(
+                               '        ',
+                               array(
+                                       'ifEmpty' => '1',
+                               ),
+                               '1',
+                       ),
+               );
+       }
+
+       /**
+        * @param string|NULL $content
+        * @param array $configuration
+        * @param string $expected
+        * @dataProvider stdWrap_ifEmptyDeterminesEmptyValuesDataProvider
+        * @test
+        */
+       public function stdWrap_ifEmptyDeterminesEmptyValues($content, array $configuration, $expected) {
+               $result = $this->subject->stdWrap_ifEmpty($content, $configuration);
+               $this->assertEquals($expected, $result);
+       }
+
+       /**
         * @param $content
         * @param array $configuration
         * @param $expected
@@ -1782,9 +1832,9 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
 
-       /////////////////////////////
+       ///////////////////////////////
        // Tests concerning getData()
-       /////////////////////////////
+       ///////////////////////////////
 
        /**
         * @return array
@@ -3663,9 +3713,9 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertEquals($expectedResult, $contentObjectRenderer->getWhere($table, $configuration));
        }
 
-       /////////////////////////////////////
-       // Test concerning link generation //
-       /////////////////////////////////////
+       ////////////////////////////////////
+       // Test concerning link generation
+       ////////////////////////////////////
 
        /**
         * @test