Unstub the passed object when calling unstub()
authorJackmcbarn <jackmcbarn@gmail.com>
Mon, 7 Jul 2014 19:36:44 +0000 (15:36 -0400)
committerJackmcbarn <jackmcbarn@gmail.com>
Mon, 7 Jul 2014 19:37:45 +0000 (15:37 -0400)
Previously, only the global was unstubbed when StubObject::unstub() was
called. Now, the object given as a parameter will also be unstubbed.
(What about other references to the object, though?)

Change-Id: I431ddd61e24686fc2f014c30064808ce57fe1706

includes/StubObject.php

index 6508bce..fb9b3e4 100644 (file)
@@ -83,9 +83,9 @@ class StubObject {
         * @param object $obj Object to check.
         * @return void
         */
-       static function unstub( $obj ) {
+       static function unstub( &$obj ) {
                if ( $obj instanceof StubObject ) {
-                       $obj->_unstub( 'unstub', 3 );
+                       $obj = $obj->_unstub( 'unstub', 3 );
                }
        }
 
@@ -134,6 +134,7 @@ class StubObject {
         * @param string $name Name of the method called in this object.
         * @param int $level Level to go in the stack trace to get the function
         *   who called this function.
+        * @return The unstubbed version of itself
         * @throws MWException
         */
        function _unstub( $name = '_unstub', $level = 2 ) {
@@ -157,6 +158,7 @@ class StubObject {
                        $GLOBALS[$this->global] = $this->_newObject();
                        --$recursionLevel;
                        wfProfileOut( $fname );
+                       return $GLOBALS[$this->global];
                }
        }
 }