File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
src/Symfony/Component/Console Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 1313
1414use Symfony \Component \Console \Application ;
1515use Symfony \Component \Console \Exception \RuntimeException ;
16+ use Symfony \Component \Console \Exception \InvalidArgumentException ;
1617use Symfony \Component \Console \Formatter \OutputFormatter ;
1718use Symfony \Component \Console \Helper \Helper ;
1819use Symfony \Component \Console \Helper \ProgressBar ;
@@ -398,7 +399,7 @@ public function newLine($count = 1)
398399 public function setInputStream ($ stream )
399400 {
400401 if (!is_resource ($ stream )) {
401- throw new \ InvalidArgumentException (sprintf ('The stream must be a valid resource, %s given ' ) , gettype ($ stream ));
402+ throw new InvalidArgumentException (sprintf ('Input stream must be a valid resource, %s given ' , gettype ($ stream) ));
402403 }
403404
404405 $ this ->inputStream = $ stream ;
Original file line number Diff line number Diff line change @@ -80,15 +80,29 @@ public function testSetInputStream()
8080 rewind ($ stream );
8181
8282 $ command ->setCode (function ($ input , $ output ) use ($ command , $ stream ) {
83- $ io = new SymfonyStyle ($ input , $ output );
83+ $ sfStyle = new SymfonyStyle ($ input , $ output );
8484
85- $ io ->setInputStream ($ stream );
86- $ io ->ask ('What \'s your name? ' );
85+ $ sfStyle ->setInputStream ($ stream );
86+ $ sfStyle ->ask ('What \'s your name? ' );
8787 });
8888
8989 $ this ->tester ->execute (array ());
9090 $ this ->assertSame (0 , $ this ->tester ->getStatusCode ());
9191 }
92+
93+ /**
94+ * @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException
95+ * @expectedMessage Input stream must be a valid resource, string given
96+ */
97+ public function testSetInputStreamWithWrongResource ()
98+ {
99+ $ this ->command ->setCode (function ($ input , $ output ) {
100+ $ sfStyle = new SymfonyStyle ($ input , $ output );
101+ $ sfStyle ->setInputStream ('invalid type ' );
102+ });
103+
104+ $ this ->tester ->execute (array ());
105+ }
92106}
93107
94108/**
You can’t perform that action at this time.
0 commit comments