-
Notifications
You must be signed in to change notification settings - Fork 47
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
1 parent
e169342
commit 14ac0e9
Showing
2 changed files
with
51 additions
and
188 deletions.
There are no files selected for viewing
188 changes: 0 additions & 188 deletions
188
tests/phpunit/src/CloudApi/AccessTokenConnectorTest.php
This file was deleted.
Oops, something went wrong.
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 | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Acquia\Cli\Tests\Commands; | ||
|
||
use Acquia\Cli\Output\Checklist; | ||
use Acquia\Cli\Tests\TestBase; | ||
use Symfony\Component\Console\Output\ConsoleOutput; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class ChecklistTest extends TestBase { | ||
|
||
protected OutputInterface $output; | ||
|
||
public function setUp(): void { | ||
// Unfortunately this prints to screen. Not sure how else to | ||
// get the spinner and checklist to work. They require the $output->section() | ||
// method which is only available for ConsoleOutput. Could make a custom testing | ||
// output class with the method. | ||
parent::setUp(); | ||
$this->output = new ConsoleOutput(); | ||
} | ||
|
||
public function testSpinner(): void { | ||
putenv('PHPUNIT_RUNNING=1'); | ||
$checklist = new Checklist($this->output); | ||
$checklist->addItem('Testing!'); | ||
|
||
// Make the spinner spin with some output. | ||
$outputCallback = static function (string $type, string $buffer) use ($checklist): void { | ||
$checklist->updateProgressBar($buffer); | ||
}; | ||
$this->localMachineHelper->execute(['echo', 'hello world'], $outputCallback, NULL, FALSE); | ||
|
||
// Complete the item. | ||
$checklist->completePreviousItem(); | ||
$items = $checklist->getItems(); | ||
/** @var \Symfony\Component\Console\Helper\ProgressBar $progressBar */ | ||
$progressBar = $items[0]['spinner']->getProgressBar(); | ||
$this->assertEquals('Testing!', $progressBar->getMessage()); | ||
$this->assertEquals('<info>✔</info>', $progressBar->getBarCharacter()); | ||
$this->assertEquals('[38;5;202m⢸[0m', $progressBar->getProgressCharacter()); | ||
$this->assertEquals('⌛', $progressBar->getEmptyBarCharacter()); | ||
$this->assertEquals(1, $progressBar->getBarWidth()); | ||
$this->assertEquals('', $progressBar->getMessage('detail')); | ||
|
||
putenv('PHPUNIT_RUNNING'); | ||
} | ||
|
||
} |