|
18 | 18 | use HyperfTest\Command\Command\FooCommand; |
19 | 19 | use HyperfTest\Command\Command\FooExceptionCommand; |
20 | 20 | use HyperfTest\Command\Command\FooExitCommand; |
| 21 | +use HyperfTest\Command\Command\FooProhibitableCommand; |
21 | 22 | use HyperfTest\Command\Command\FooTraitCommand; |
22 | 23 | use HyperfTest\Command\Command\SwooleFlagsCommand; |
23 | 24 | use HyperfTest\Command\Command\Traits\Foo; |
@@ -101,4 +102,31 @@ public function testExitCodeWhenThrowExceptionInCoroutine() |
101 | 102 | { |
102 | 103 | $this->testExitCodeWhenThrowException(); |
103 | 104 | } |
| 105 | + |
| 106 | + public function testProhibitableCommand() |
| 107 | + { |
| 108 | + $application = Mockery::mock(ConsoleApplication::class); |
| 109 | + $application->shouldReceive('getHelperSet'); |
| 110 | + |
| 111 | + $output = Mockery::mock(OutputInterface::class); |
| 112 | + $command = new ClassInvoker(new FooProhibitableCommand()); |
| 113 | + $command->setApplication($application); |
| 114 | + $command->setOutput($output); |
| 115 | + $input = Mockery::mock(InputInterface::class); |
| 116 | + $input->shouldReceive('getOption')->andReturnFalse(); |
| 117 | + $result = $command->execute($input, $output); |
| 118 | + $this->assertSame(FooProhibitableCommand::SUCCESS, $result); |
| 119 | + |
| 120 | + FooProhibitableCommand::prohibit(true); |
| 121 | + |
| 122 | + $output = Mockery::mock(OutputInterface::class); |
| 123 | + $output->shouldReceive('warn')->andReturn(); |
| 124 | + $command = new ClassInvoker(new FooProhibitableCommand()); |
| 125 | + $command->setApplication($application); |
| 126 | + $command->setOutput($output); |
| 127 | + $input = Mockery::mock(InputInterface::class); |
| 128 | + $input->shouldReceive('getOption')->andReturnFalse(); |
| 129 | + $result = $command->execute($input, $output); |
| 130 | + $this->assertSame(FooProhibitableCommand::FAILURE, $result); |
| 131 | + } |
104 | 132 | } |
0 commit comments