File tree 2 files changed +19
-4
lines changed
src/Symfony/Component/Console
2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \Console \Application ;
15
15
use Symfony \Component \Console \Exception \RuntimeException ;
16
+ use Symfony \Component \Console \Exception \InvalidArgumentException ;
16
17
use Symfony \Component \Console \Formatter \OutputFormatter ;
17
18
use Symfony \Component \Console \Helper \Helper ;
18
19
use Symfony \Component \Console \Helper \ProgressBar ;
@@ -398,7 +399,7 @@ public function newLine($count = 1)
398
399
public function setInputStream ($ stream )
399
400
{
400
401
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) ));
402
403
}
403
404
404
405
$ this ->inputStream = $ stream ;
Original file line number Diff line number Diff line change @@ -80,15 +80,29 @@ public function testSetInputStream()
80
80
rewind ($ stream );
81
81
82
82
$ command ->setCode (function ($ input , $ output ) use ($ command , $ stream ) {
83
- $ io = new SymfonyStyle ($ input , $ output );
83
+ $ sfStyle = new SymfonyStyle ($ input , $ output );
84
84
85
- $ io ->setInputStream ($ stream );
86
- $ io ->ask ('What \'s your name? ' );
85
+ $ sfStyle ->setInputStream ($ stream );
86
+ $ sfStyle ->ask ('What \'s your name? ' );
87
87
});
88
88
89
89
$ this ->tester ->execute (array ());
90
90
$ this ->assertSame (0 , $ this ->tester ->getStatusCode ());
91
91
}
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
+ }
92
106
}
93
107
94
108
/**
You can’t perform that action at this time.
0 commit comments