Is there a way to mock a procedural function from common.inc in a test without an external library?
I have found a solution on this page: https://www.drupal.org/docs/8/phpunit/unit-testing-more-complicated-drupal-classes


  You can mock a global function by adding fixtures in your test module.
  Let's say that you need to mock base_path(). 
  
  
  Simple go add a fixture in your testing src 
  Add a mock for function, for example, you can
  define like above: 
  Simply use require_once on your setup and you get your mocked function available and replaceable only in the test you are requiring. Make sure to use function_exists() to check if the function you need to test isn't already available.
  


 /**
  * Overrides global function if not exists.
  *
  * @return string
  *   Base path mocked.
  */
  function base_path() {
    if (!function_exists('base_path')) {
      return '/';
    }
  }


In my case, I have used fixtures, as refactoring the code was out of question.

As the documentation says, I've created a mocked function in tests/fixtures/function_name.php and included the file into the setUp() method of the test with require_once. This way, I've had my own global function in the test's scope.