[FEATURE] Add closure support for t3lib_div::callUserFunction
[Packages/TYPO3.CMS.git] / tests / Unit / t3lib / class.t3lib_divTest.php
index 03512e1..3434513 100644 (file)
@@ -4085,6 +4085,7 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $inputData = array('foo' => 'bar');
                t3lib_div::callUserFunction($functionName, $inputData, $this, 'user_', 2);
        }
+
        /**
         * Data provider for callUserFunctionInvalidParameterDataprovider and
         * callUserFunctionWillThrowExceptionForInvalidParameters.
@@ -4161,6 +4162,20 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $params['called'][spl_object_hash($this)]++;
        }
 
+       /**
+        * @test
+        */
+       public function callUserFunctionAcceptsClosures() {
+               $inputData = array('foo' => 'bar');
+               $closure = function($parameters, $reference) use($inputData) {
+                       $reference->assertEquals($inputData, $parameters, 'Passed data doesn\'t match expected output');
+                       return 'Worked fine';
+               };
+
+               $this->assertEquals('Worked fine', t3lib_div::callUserFunction($closure, $inputData, $this));
+       }
+
+
        ///////////////////////////////////////////////////
        // Tests concerning hasValidClassPrefix
        ///////////////////////////////////////////////////