Skip to content

Commit

Permalink
checklist
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed May 16, 2024
1 parent e169342 commit 14ac0e9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 188 deletions.
188 changes: 0 additions & 188 deletions tests/phpunit/src/CloudApi/AccessTokenConnectorTest.php

This file was deleted.

51 changes: 51 additions & 0 deletions tests/phpunit/src/Commands/ChecklistTest.php
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('⢸', $progressBar->getProgressCharacter());
$this->assertEquals('', $progressBar->getEmptyBarCharacter());
$this->assertEquals(1, $progressBar->getBarWidth());
$this->assertEquals('', $progressBar->getMessage('detail'));

putenv('PHPUNIT_RUNNING');
}

}

0 comments on commit 14ac0e9

Please sign in to comment.