public function test_remove_default_command_path()
 {
     $paths = $this->paths;
     $paths[] = $path = trim(shell_exec('which mysql ' . ignore_stderr()));
     if (!$path) {
         $this->markTestSkipped('Couldn\'t find mysql');
     }
     unset($paths['mysql']);
     shuffle($paths);
     $this->assertEquals($path, Backup_Utilities::get_executable_path($paths));
 }
 /**
  * Attempt to work out path to a cli executable.
  *
  * @param  array $paths An array of paths to check against.
  *
  * @return string|false        The path to the executable.
  */
 public static function get_executable_path($paths)
 {
     if (!self::is_exec_available()) {
         return false;
     }
     $paths = array_map('wp_normalize_path', $paths);
     foreach ($paths as $path) {
         $output = $result = 0;
         /**
          * Attempt to call `--version` on each path, the one which works
          * must be the correct path.
          *
          * We pipe STDERR to /dev/null so we don't leak errors.
          */
         exec(escapeshellarg($path) . ' --version ' . ignore_stderr(), $output, $result);
         // If the command executed successfully then this must be the correct path
         if ($result === 0) {
             return $path;
         }
     }
     return false;
 }