diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index e8efb2a853fa..4b6d3d2c371e 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -197,7 +197,9 @@ public static function init() { // If the command is being called from a controller // we need to define STDOUT ourselves + // @codeCoverageIgnoreStart define('STDOUT', 'php://output'); + // @codeCoverageIgnoreEnd } } @@ -249,7 +251,8 @@ public static function input(string $prefix = null): string * @param string|array $options String to a default value, array to a list of options (the first option will be the default value) * @param string $validation Validation rules * - * @return string The user input + * @return string The user input + * * @codeCoverageIgnore */ public static function prompt(string $field, $options = null, string $validation = null): string @@ -309,7 +312,8 @@ public static function prompt(string $field, $options = null, string $validation * @param string $value Input value * @param string $rules Validation rules * - * @return boolean + * @return boolean + * * @codeCoverageIgnore */ protected static function validate(string $field, string $value, string $rules): bool @@ -488,7 +492,8 @@ public static function newLine(int $num = 1) /** * Clears the screen of output * - * @return void + * @return void + * * @codeCoverageIgnore */ public static function clearScreen() @@ -759,8 +764,10 @@ public static function generateDimensions() } else { + // @codeCoverageIgnoreStart static::$height = (int) exec('tput lines'); static::$width = (int) exec('tput cols'); + // @codeCoverageIgnoreEnd } } } @@ -1139,8 +1146,8 @@ public static function table(array $tbody, array $thead = []) * For now, just echo the content, but look into a better * solution down the road. * - * @param $handle - * @param string $string + * @param resource $handle + * @param string $string */ protected static function fwrite($handle, string $string) { @@ -1150,7 +1157,9 @@ protected static function fwrite($handle, string $string) return; } + // @codeCoverageIgnoreStart echo $string; + // @codeCoverageIgnoreEnd } } diff --git a/tests/system/CLI/CLITest.php b/tests/system/CLI/CLITest.php index 6c6302d504f5..5cca0d260c7f 100644 --- a/tests/system/CLI/CLITest.php +++ b/tests/system/CLI/CLITest.php @@ -336,7 +336,14 @@ public function testParseCommandMultipleOptions() public function testWindow() { + $height = new \ReflectionProperty(CLI::class, 'height'); + $height->setAccessible(true); + $height->setValue(null); $this->assertTrue(is_int(CLI::getHeight())); + + $width = new \ReflectionProperty(CLI::class, 'width'); + $width->setAccessible(true); + $width->setValue(null); $this->assertTrue(is_int(CLI::getWidth())); }