Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Console\Tests\Completion\Output; | ||
|
||
use Symfony\Component\Console\Completion\Output\BashCompletionOutput; | ||
use Symfony\Component\Console\Completion\Output\CompletionOutputInterface; | ||
|
||
class BashCompletionOutputTest extends CompletionOutputTestCase | ||
{ | ||
public function getCompletionOutput(): CompletionOutputInterface | ||
{ | ||
return new BashCompletionOutput(); | ||
} | ||
|
||
public function getExpectedOptionsOutput(): string | ||
{ | ||
return "--option1\n--negatable\n--no-negatable".\PHP_EOL; | ||
} | ||
|
||
public function getExpectedValuesOutput(): string | ||
{ | ||
return "Green\nRed\nYellow".\PHP_EOL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Console\Tests\Completion\Output; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Console\Completion\CompletionSuggestions; | ||
use Symfony\Component\Console\Completion\Output\CompletionOutputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\StreamOutput; | ||
|
||
abstract class CompletionOutputTestCase extends TestCase | ||
{ | ||
abstract public function getCompletionOutput(): CompletionOutputInterface; | ||
|
||
abstract public function getExpectedOptionsOutput(): string; | ||
|
||
abstract public function getExpectedValuesOutput(): string; | ||
|
||
public function testOptionsOutput() | ||
{ | ||
$options = [ | ||
new InputOption('option1', 'o', InputOption::VALUE_NONE), | ||
new InputOption('negatable', null, InputOption::VALUE_NEGATABLE), | ||
]; | ||
$suggestions = new CompletionSuggestions(); | ||
$suggestions->suggestOptions($options); | ||
$stream = fopen('php://memory', 'rw+'); | ||
$this->getCompletionOutput()->write($suggestions, new StreamOutput($stream)); | ||
fseek($stream, 0); | ||
$this->assertEquals($this->getExpectedOptionsOutput(), stream_get_contents($stream)); | ||
} | ||
|
||
public function testValuesOutput() | ||
{ | ||
$suggestions = new CompletionSuggestions(); | ||
$suggestions->suggestValues(['Green', 'Red', 'Yellow']); | ||
$stream = fopen('php://memory', 'rw+'); | ||
$this->getCompletionOutput()->write($suggestions, new StreamOutput($stream)); | ||
fseek($stream, 0); | ||
$this->assertEquals($this->getExpectedValuesOutput(), stream_get_contents($stream)); | ||
} | ||
} |