[TASK] Add possibility creating accessible mock for abstract classes 15/25315/4
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Tue, 12 Nov 2013 15:09:30 +0000 (16:09 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 1 Feb 2014 22:50:02 +0000 (23:50 +0100)
Resolves: #53564
Releases: 6.0, 6.1, 6.2
Change-Id: If7d69e4f87e368c1eef672cb68f1af92d6ae501b
Reviewed-on: https://review.typo3.org/25315
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Tests/BaseTestCase.php

index 64ca9d1..1d2d1db 100644 (file)
@@ -84,6 +84,40 @@ abstract class BaseTestCase extends \PHPUnit_Framework_TestCase {
                );
        }
 
+       /**
+        * Returns a mock object which allows for calling protected methods and access
+        * of protected properties.
+        *
+        * @param string $originalClassName Full qualified name of the original class
+        * @param array $arguments
+        * @param string $mockClassName
+        * @param boolean $callOriginalConstructor
+        * @param boolean $callOriginalClone
+        * @param boolean $callAutoload
+        *
+        * @throws \InvalidArgumentException
+        *
+        * @return \PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface
+        *
+        */
+       protected function getAccessibleMockForAbstractClass(
+               $originalClassName, array $arguments = array(), $mockClassName = '',
+               $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE
+       ) {
+               if ($originalClassName === '') {
+                       throw new \InvalidArgumentException('$originalClassName must not be empty.', 1384268260);
+               }
+
+               return $this->getMockForAbstractClass(
+                       $this->buildAccessibleProxy($originalClassName),
+                       $arguments,
+                       $mockClassName,
+                       $callOriginalConstructor,
+                       $callOriginalClone,
+                       $callAutoload
+               );
+       }
+
        /**
         * Creates a proxy class of the specified class which allows
         * for calling even protected methods and access of protected properties.