Skip to content

Commit

Permalink
test connects with autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
jpuck committed May 10, 2017
1 parent 277add7 commit ace2e92
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/unit/ConnectTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use gpgl\console\Commands\{Get,Connect};
use gpgl\console\Container;

class ConnectTest extends TestCase
{
protected $filename_nopw = __DIR__.'/../fixtures/nopw.gpgldb';

protected function setUp()
{
putenv('GPGL_DB');
Container::unsetDbms();
}

protected function tearDown()
{
putenv('GPGL_DB');
Container::unsetDbms();
}

public function test_connects_with_tab_completion()
{
$app = new Application;
$app->add(new Get);
$app->add(new Connect);

$command = $app->find('connect');
$commandTester = new CommandTester($command);

// tab completion 'get one password'
$commandTester->setInputs(["g\t o\tp\t"]);
$commandTester->execute(array(
'command' => $command->getName(),
'--database' => $this->filename_nopw,
));

$output = $commandTester->getDisplay();
$this->assertContains('nopw', $output);
$this->assertNotContains('none', $output);
}
}

0 comments on commit ace2e92

Please sign in to comment.