| @@ 213-238 (lines=26) @@ | ||
| 210 | /** |
|
| 211 | * Test run command without class. |
|
| 212 | */ |
|
| 213 | public function testRunCommandWithoutClass() |
|
| 214 | { |
|
| 215 | $configCallback = function (ApplicationConfig $config) { |
|
| 216 | $config |
|
| 217 | ->beginCommand('create-blog') |
|
| 218 | ->setDescription('Create a new blog') |
|
| 219 | // should set ->setClass() |
|
| 220 | ->end() |
|
| 221 | ; |
|
| 222 | }; |
|
| 223 | ||
| 224 | $this |
|
| 225 | ->given($config = $this->createConfiguration()) |
|
| 226 | ->and($configCallback($config)) |
|
| 227 | ->and($application = $this->createApplication($config)) |
|
| 228 | ->and($args = new ArgvArgs(array('test', 'create-blog'))) |
|
| 229 | ->and($input = new StringInputStream('')) |
|
| 230 | ->and($output = new BufferedOutputStream()) |
|
| 231 | ->and($errorOutput = new BufferedOutputStream()) |
|
| 232 | ->then() |
|
| 233 | ->exception(function () use ($application, $args, $input, $output, $errorOutput) { |
|
| 234 | $application->run($args, $input, $output, $errorOutput); |
|
| 235 | }) |
|
| 236 | ->isInstanceOf(\RuntimeException::class) |
|
| 237 | ; |
|
| 238 | } |
|
| 239 | ||
| 240 | /** |
|
| 241 | * Test run command without arguments. |
|
| @@ 243-269 (lines=27) @@ | ||
| 240 | /** |
|
| 241 | * Test run command without arguments. |
|
| 242 | */ |
|
| 243 | public function testRunCommandWithoutArguments() |
|
| 244 | { |
|
| 245 | $configCallback = function (ApplicationConfig $config) { |
|
| 246 | $config |
|
| 247 | ->beginCommand('create-blog') |
|
| 248 | ->setDescription('Create a new blog') |
|
| 249 | ->setClass(CreateBlogCommand::class) |
|
| 250 | // should have ->addArgument('name', Argument::REQUIRED | Argument::STRING, 'The blog name') |
|
| 251 | ->end() |
|
| 252 | ; |
|
| 253 | }; |
|
| 254 | ||
| 255 | $this |
|
| 256 | ->given($config = $this->createConfiguration()) |
|
| 257 | ->and($configCallback($config)) |
|
| 258 | ->and($application = $this->createApplication($config)) |
|
| 259 | ->and($args = new ArgvArgs(array('test', 'create-blog'))) |
|
| 260 | ->and($input = new StringInputStream('')) |
|
| 261 | ->and($output = new BufferedOutputStream()) |
|
| 262 | ->and($errorOutput = new BufferedOutputStream()) |
|
| 263 | ->then() |
|
| 264 | ->exception(function () use ($application, $args, $input, $output, $errorOutput) { |
|
| 265 | $application->run($args, $input, $output, $errorOutput); |
|
| 266 | }) |
|
| 267 | ->isInstanceOf(\InvalidArgumentException::class) |
|
| 268 | ; |
|
| 269 | } |
|
| 270 | ||
| 271 | /** |
|
| 272 | * Test run command with default handlers. |
|