1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- /**
- * This file is part of the DigitalOcean library.
- *
- * (c) Antoine Corcy <contact@sbin.dk>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace DigitalOcean\Tests\CLI\Images;
- use Symfony\Component\Console\Application;
- use Symfony\Component\Console\Tester\CommandTester;
- use DigitalOcean\Tests\TestCase;
- use DigitalOcean\CLI\Images\ShowCommand;
- /**
- * @author Antoine Corcy <contact@sbin.dk>
- */
- class ShowCommandTest extends TestCase
- {
- protected $application;
- protected $command;
- protected $commandTester;
- protected function setUp()
- {
- $this->application = new Application();
- $result = (object) array(
- 'image' => (object) array('id' => 1, 'name' => 'foo', 'distribution' => 'foobar dist')
- );
- $ShowCommand = $this->getMock('\DigitalOcean\CLI\Images\ShowCommand', array('getDigitalOcean'));
- $ShowCommand
- ->expects($this->any())
- ->method('getDigitalOcean')
- ->will($this->returnValue($this->getMockDigitalOcean('images', $this->getMockImages('show', $result))));
- $this->application->add($ShowCommand);
- $this->command = $this->application->find('images:show');
- $this->commandTester = new CommandTester($this->command);
- }
- /**
- * @expectedException \RuntimeException
- * @expectedExceptionMessage Not enough arguments.
- */
- public function testExecuteNotEnoughArguments()
- {
- $this->commandTester->execute(array(
- 'command' => $this->command->getName(),
- ));
- }
- public function testExecute()
- {
- $this->commandTester->execute(array(
- 'command' => $this->command->getName(),
- 'id' => 123,
- ));
- $expected = <<<EOT
- +----+------+--------------+
- | ID | Name | Distribution |
- +----+------+--------------+
- | 1 | foo | foobar dist |
- +----+------+--------------+
- EOT
- ;
- $this->assertTrue(is_string($this->commandTester->getDisplay()));
- $this->assertSame($expected, $this->commandTester->getDisplay());
- }
- }
|