diff --git a/src/Lunr/Halo/LunrBaseTest.php b/src/Lunr/Halo/LunrBaseTest.php
index 3b7e20bac956b3184efa0952d1c206eb234a51cf..e6d2e0ede49a5502012269374aff67d37d9b60c6 100644
--- a/src/Lunr/Halo/LunrBaseTest.php
+++ b/src/Lunr/Halo/LunrBaseTest.php
@@ -23,11 +23,15 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
 {
 
     /**
+     * Identifier string for backup functions.
+     * @var String
+     */
+    const FUNCTION_ID = '_lunrbackup';
+    /**
      * Instance of the tested class.
      * @var mixed
      */
     protected $class;
-
     /**
      * Reflection instance of the tested class.
      * @var ReflectionClass
@@ -35,12 +39,6 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
     protected $reflection;
 
     /**
-     * Identifier string for backup functions.
-     * @var String
-     */
-    const FUNCTION_ID = '_lunrbackup';
-
-    /**
      * Testcase Destructor.
      */
     public function tearDown()
@@ -50,21 +48,6 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * Get an accessible ReflectionProperty.
-     *
-     * @param String $property Property name
-     *
-     * @return ReflectionProperty $return The ReflectionProperty instance
-     */
-    protected function get_accessible_reflection_property($property)
-    {
-        $return = $this->reflection->getProperty($property);
-        $return->setAccessible(TRUE);
-
-        return $return;
-    }
-
-    /**
      * Get an accessible ReflectionMethod.
      *
      * @param String $method Method name
@@ -89,7 +72,23 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
      */
     protected function set_reflection_property_value($property, $value)
     {
-        $this->get_accessible_reflection_property($property)->setValue($this->class, $value);
+        $this->get_accessible_reflection_property($property)
+             ->setValue($this->class, $value);
+    }
+
+    /**
+     * Get an accessible ReflectionProperty.
+     *
+     * @param String $property Property name
+     *
+     * @return ReflectionProperty $return The ReflectionProperty instance
+     */
+    protected function get_accessible_reflection_property($property)
+    {
+        $return = $this->reflection->getProperty($property);
+        $return->setAccessible(TRUE);
+
+        return $return;
     }
 
     /**
@@ -101,7 +100,8 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
      */
     protected function get_reflection_property_value($property)
     {
-        return $this->get_accessible_reflection_property($property)->getValue($this->class);
+        return $this->get_accessible_reflection_property($property)
+                    ->getValue($this->class);
     }
 
     /**
@@ -114,6 +114,26 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
      */
     protected function mock_function($name, $mock)
     {
+        if (PHP_MAJOR_VERSION < 7)
+        {
+            $this->runkit_mock_function($name, $mock);
+
+            return;
+        }
+
+        $this->uopz_mock_function($name, $mock);
+    }
+
+    /**
+     * Mock a PHP function with runkit.
+     *
+     * @param String $name Function name
+     * @param String $mock Replacement code for the function
+     *
+     * @return void
+     */
+    private function runkit_mock_function($name, $mock)
+    {
         if (function_exists($name . self::FUNCTION_ID) === FALSE)
         {
             runkit_function_copy($name, $name . self::FUNCTION_ID);
@@ -123,6 +143,22 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
     }
 
     /**
+     * Mock a PHP function with uopz.
+     *
+     * @param String $name Function name
+     * @param String $mock Replacement code for the function
+     *
+     * @return void
+     */
+    private function uopz_mock_function($name, $mock)
+    {
+        uopz_set_return($name, function () use ($mock)
+        {
+            return eval($mock);
+        }, TRUE);
+    }
+
+    /**
      * Unmock a PHP function.
      *
      * @param String $name Function name
@@ -131,11 +167,42 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
      */
     protected function unmock_function($name)
     {
+        if (PHP_MAJOR_VERSION < 7)
+        {
+            $this->runkit_unmock_function($name);
+
+            return;
+        }
+
+        $this->uopz_unmock_function($name);
+    }
+
+    /**
+     * Unmock a PHP function with runkit.
+     *
+     * @param String $name Function name
+     *
+     * @return void
+     */
+    private function runkit_unmock_function($name)
+    {
         runkit_function_remove($name);
         runkit_function_rename($name . self::FUNCTION_ID, $name);
     }
 
     /**
+     * Unmock a PHP function with uopz.
+     *
+     * @param String $name Function name
+     *
+     * @return void
+     */
+    private function uopz_unmock_function($name)
+    {
+        uopz_unset_return($name);
+    }
+
+    /**
      * Mock a method.
      *
      * Replace the code of a function of a specific class
@@ -149,6 +216,31 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
      */
     protected function mock_method($method, $mock, $visibility = 'public', $args = '')
     {
+        if (PHP_MAJOR_VERSION < 7)
+        {
+            $this->runkit_mock_method($method, $mock, $visibility, $args);
+
+            return;
+        }
+
+        //UOPZ does not support changing the visibility with the currently used function
+        $this->uopz_mock_method($method, $mock, $args);
+    }
+
+    /**
+     * Mock a method with runkit.
+     *
+     * Replace the code of a function of a specific class
+     *
+     * @param Callable $method     Method defined in an array form
+     * @param String   $mock       Replacement code for the method
+     * @param String   $visibility Visibility of the redefined method
+     * @param String   $args       Comma-delimited list of arguments for the redefined method
+     *
+     * @return void
+     */
+    private function runkit_mock_method($method, $mock, $visibility = 'public', $args = '')
+    {
         $class_name  = is_object($method[0]) ? get_class($method[0]) : $method[0];
         $method_name = $method[1];
 
@@ -157,7 +249,8 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
             runkit_method_copy($class_name, $method_name . self::FUNCTION_ID, $class_name, $method_name);
         }
 
-        switch ($visibility) {
+        switch ($visibility)
+        {
             case 'public':
                 $visibility_flag = RUNKIT_ACC_PUBLIC;
                 break;
@@ -173,6 +266,31 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
     }
 
     /**
+     * Mock a method with uopz.
+     *
+     * Replace the code of a function of a specific class
+     *
+     * @param Callable $method Method defined in an array form
+     * @param String   $mock   Replacement code for the method
+     * @param String   $args   Comma-delimited list of arguments for the redefined method
+     *
+     * @return void
+     */
+    private function uopz_mock_method($method, $mock, $args = '')
+    {
+        $class_name  = is_object($method[0]) ? get_class($method[0]) : $method[0];
+        $method_name = $method[1];
+
+        $function = function () use ($mock)
+        {
+            return eval($mock);
+        };
+
+        uopz_set_return($class_name, $method_name, call_user_func_array($function, explode(',', $args)));
+
+    }
+
+    /**
      * Unmock a method.
      *
      * @param Callable $method Method defined in an array form
@@ -181,6 +299,25 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
      */
     protected function unmock_method($method)
     {
+        if (PHP_MAJOR_VERSION < 7)
+        {
+            $this->runkit_unmock_method($method);
+
+            return;
+        }
+
+        $this->uopz_unmock_method($method);
+    }
+
+    /**
+     * Unmock a method with runkit.
+     *
+     * @param Callable $method Method defined in an array form
+     *
+     * @return void
+     */
+    private function runkit_unmock_method($method)
+    {
         $class_name  = is_object($method[0]) ? get_class($method[0]) : $method[0];
         $method_name = $method[1];
 
@@ -189,6 +326,47 @@ abstract class LunrBaseTest extends PHPUnit_Framework_TestCase
     }
 
     /**
+     * Unmock a method with uopz.
+     *
+     * @param Callable $method Method defined in an array form
+     *
+     * @return void
+     */
+    private function uopz_unmock_method($method)
+    {
+        $class_name  = is_object($method[0]) ? get_class($method[0]) : $method[0];
+        $method_name = $method[1];
+
+        uopz_unset_return($class_name, $method_name);
+    }
+
+    /**
+     * Redefine a constant with runkit or uopz
+     *
+     * TODO: Figure out why this won' work
+     *
+     * @param string $constant The constant
+     * @param mixed  $value    New value
+     *
+     * @return void
+     */
+    protected function constant_redefine($constant, $value)
+    {
+        if (PHP_MAJOR_VERSION < 7)
+        {
+            runkit_constant_redefine($constant, $value);
+
+            return;
+        }
+
+        $constant = explode('::', $constant);
+        $class_name = $constant[0];
+        $constant_name = $constant[1];
+
+        uopz_redefine($class_name, $constant_name, $value);
+    }
+
+    /**
      * Assert that a property value equals the expected value.
      *
      * @param String $property Property name
