| 1 | <?php |
||
| 7 | class CommandCollectorTest extends TestCase |
||
| 8 | { |
||
| 9 | |||
| 10 | public function tearDown() |
||
| 11 | { |
||
| 12 | Mockery::close(); |
||
| 13 | } |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @test |
||
| 17 | */ |
||
| 18 | public function canCollectCommands() |
||
| 19 | { |
||
| 20 | $container = Mockery::mock(Container::class); |
||
| 21 | $mock = Mockery::mock(MockCommand::class); |
||
| 22 | $container->shouldReceive('get')->with(MockCommand::class)->andReturn($mock)->once(); |
||
| 23 | |||
| 24 | $collector = new CommandCollector(); |
||
| 25 | $collector->setContainer($container); |
||
| 26 | $collector->addCommand(MockCommand::class); |
||
| 27 | $result = $collector->getCommands(); |
||
| 28 | |||
| 29 | $this->assertSame([$mock], $result); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @test |
||
| 34 | */ |
||
| 35 | public function canHandleInvalidCommandClassName() |
||
| 36 | { |
||
| 37 | $this->expectException(InvalidArgumentException::class); |
||
| 38 | $this->expectExceptionMessage('Provided command "stdClass" doesn\'t extend Venta\Console\Command class.'); |
||
| 39 | |||
| 40 | $collector = new CommandCollector(Mockery::mock(Container::class)); |
||
| 41 | $collector->addCommand(stdClass::class); |
||
| 42 | } |
||
| 43 | |||
| 44 | } |
||
| 45 |