From 179622c2421ee55ae2ec4ef33d99aade3f7a05c3 Mon Sep 17 00:00:00 2001 From: dishitpala Date: Fri, 3 Apr 2020 01:04:56 +0530 Subject: [PATCH] Remove is-bundled-command method with test-case --- php/utils.php | 32 ----------------------- tests/test-bundled-commands.php | 46 --------------------------------- 2 files changed, 78 deletions(-) delete mode 100644 tests/test-bundled-commands.php diff --git a/php/utils.php b/php/utils.php index 12c1d00e06..547a63dd13 100644 --- a/php/utils.php +++ b/php/utils.php @@ -1280,38 +1280,6 @@ function phar_safe_path( $path ) { ); } -/** - * Check whether a given Command object is part of the bundled set of - * commands. - * - * This function accepts both a fully qualified class name as a string as - * well as an object that extends `WP_CLI\Dispatcher\CompositeCommand`. - * - * @param \WP_CLI\Dispatcher\CompositeCommand|string $command - * @return bool - */ -function is_bundled_command( $command ) { - static $classes; - - if ( null === $classes ) { - $classes = array(); - // TODO: This needs to be rebuilt. - // $class_map = WP_CLI_VENDOR_DIR . '/composer/autoload_commands_classmap.php'; - // if ( file_exists( WP_CLI_VENDOR_DIR . '/composer/' ) ) { - // $classes = include $class_map; - // } - $classes = array( 'CLI_Command' => true ); - } - - if ( is_object( $command ) ) { - $command = get_class( $command ); - } - - return is_string( $command ) - ? array_key_exists( $command, $classes ) - : false; -} - /** * Maybe prefix command string with "/usr/bin/env". * Removes (if there) if Windows, adds (if not there) if not. diff --git a/tests/test-bundled-commands.php b/tests/test-bundled-commands.php deleted file mode 100644 index 79075fb1dc..0000000000 --- a/tests/test-bundled-commands.php +++ /dev/null @@ -1,46 +0,0 @@ -assertEquals( $expected_result, $result ); - } - - public function dataProviderIsBundledCommands() { - return array( - // Bundled commands. - array( 'CLI_Command', true ), - array( new CLI_Command(), true ), - - // Commands not bundled. - array( 'Random_Unknown_Command', false ), - array( new Random_Unknown_Command(), false ), - - // Wrong data types. - array( array( 'CLI_Command' ), false ), - array( new stdClass(), false ), - array( 42, false ), - array( null, false ), - ); - } -}