From 96c91211dd004b24eee6c7aea330942edb5669a5 Mon Sep 17 00:00:00 2001 From: Toon Verwerft Date: Wed, 4 Jan 2017 07:06:23 +0100 Subject: [PATCH] Fix #254 --- spec/GrumPHP/IO/ConsoleIOSpec.php | 21 ++++++++++++++++++++- src/GrumPHP/IO/ConsoleIO.php | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/spec/GrumPHP/IO/ConsoleIOSpec.php b/spec/GrumPHP/IO/ConsoleIOSpec.php index 4e3250234..2e3f960cb 100644 --- a/spec/GrumPHP/IO/ConsoleIOSpec.php +++ b/spec/GrumPHP/IO/ConsoleIOSpec.php @@ -88,9 +88,28 @@ function it_reads_command_input() $this->readCommandInput($handle)->shouldBe('input'); } + function it_reads_actual_diffs_from_input() + { + $diff = <<mockHandle($diff); + $this->readCommandInput($handle)->shouldBe($diff); + } + function it_knows_empty_command_input() { - $handle = $this->mockHandle("\r\n\t\f "); + $handle = $this->mockHandle(" \r\n\t\f "); $this->readCommandInput($handle)->shouldBe(''); } diff --git a/src/GrumPHP/IO/ConsoleIO.php b/src/GrumPHP/IO/ConsoleIO.php index 9ff330527..93a571eec 100644 --- a/src/GrumPHP/IO/ConsoleIO.php +++ b/src/GrumPHP/IO/ConsoleIO.php @@ -121,7 +121,7 @@ public function readCommandInput($handle) } // When the input only consist of white space characters, we assume that there is no input. - $this->stdin = !preg_match('/^([\s]*)$/m', $input) ? $input : ''; + $this->stdin = !preg_match_all('/^([\s]*)$/', $input) ? $input : ''; return $this->stdin; }