Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix failing build
  • Loading branch information
veewee committed May 31, 2017
commit c1c03d371044d2b4142e6a614e6cd4e35e379891
46 changes: 21 additions & 25 deletions spec/Event/Subscriber/ProgressSubscriberSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@
use GrumPHP\Task\TaskInterface;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class ProgressSubscriberSpec extends ObjectBehavior
{
function let(OutputInterface $output, ProgressBar $progressBar)
function let(OutputInterface $output)
{
$output->getVerbosity()->willReturn(OutputInterface::VERBOSITY_NORMAL);
$output->isDecorated()->willReturn(false);
$output->getFormatter()->willReturn(new OutputFormatter());

$progressBar = new ProgressBar($output->getWrappedObject());

$this->beConstructedWith($output, $progressBar);
}

Expand All @@ -35,53 +42,42 @@ function it_should_subscribe_to_events()
$this->getSubscribedEvents()->shouldBeArray();
}

function it_starts_progress(ProgressBar $progressBar, RunnerEvent $event, TasksCollection $tasks)
function it_starts_progress(OutputInterface $output, RunnerEvent $event, TasksCollection $tasks)
{
$tasks->count()->willReturn(2);
$event->getTasks()->willReturn($tasks);

$progressBar->setFormat(Argument::type('string'))->shouldBeCalled();
$progressBar->setOverwrite(false)->shouldBeCalled();
$progressBar->setMessage(Argument::type('string'))->shouldBeCalled();
$progressBar->start(2)->shouldBeCalled();
$output->write('<fg=yellow>GrumPHP is sniffing your code!</fg=yellow>')->shouldBeCalled();

$this->startProgress($event);
}

function it_should_advance_progress(ProgressBar $progressBar, TaskEvent $event, TaskInterface $task)
function it_should_advance_progress(OutputInterface $output, TaskEvent $event, TaskInterface $task)
{
$this->beConstructedWith($output, $progress = new ProgressBar($output->getWrappedObject(), 2));

$event->getTask()->willReturn($task);

$progressBar->setFormat(Argument::type('string'))->shouldBeCalled();
$progressBar->setOverwrite(false)->shouldBeCalled();
$progressBar->setMessage(Argument::type('string'))->shouldBeCalled();
$progressBar->advance()->shouldBeCalled();
$output->writeln('')->shouldBeCalled();
$output->write(Argument::containingString('Running task'))->shouldBeCalled();
$output->write(Argument::containingString('1/2'))->shouldBeCalled();

$this->advanceProgress($event);
}

function it_finishes_progress(OutputInterface $output, ProgressBar $progressBar, RunnerEvent $event)
function it_finishes_progress(OutputInterface $output, RunnerEvent $event)
{
$progressBar->getProgress()->willReturn(1);
$progressBar->getMaxSteps()->willReturn(1);
$this->beConstructedWith($output, $progress = new ProgressBar($output->getWrappedObject(), 0));

$progressBar->setOverwrite(false)->shouldBeCalled();
$progressBar->finish()->shouldBeCalled();
$output->writeln('')->shouldBeCalled();

$this->finishProgress($event);
}

function it_finishes_progress_early(OutputInterface $output, ProgressBar $progressBar, RunnerEvent $event)
function it_finishes_progress_early(OutputInterface $output, RunnerEvent $event)
{
$progressBar->getProgress()->willReturn(1);
$progressBar->getMaxSteps()->willReturn(2);

$progressBar->setFormat(Argument::type('string'))->shouldBeCalled();
$progressBar->setMessage(Argument::type('string'))->shouldBeCalled();

$progressBar->setOverwrite(false)->shouldBeCalled();
$progressBar->finish()->shouldBeCalled();
$this->beConstructedWith($output, $progress = new ProgressBar($output->getWrappedObject(), 2));
$output->write('<fg=red>Aborted ...</fg=red>')->shouldBeCalled();
$output->writeln('')->shouldBeCalled();

$this->finishProgress($event);
Expand Down