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

Skip to content

Commit 2424f11

Browse files
authored
Merge pull request #364 from veewee/fix-symfony-progressbar-issues
Fix symfony progressbar issues
2 parents c57aeff + 5ecdc9c commit 2424f11

File tree

3 files changed

+21
-29
lines changed

3 files changed

+21
-29
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ php:
44
- 5.6
55
- 7.0
66
- 7.1
7-
- hhvm
87
- nightly
98

109
env:

spec/Event/Subscriber/ProgressSubscriberSpec.php

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@
99
use GrumPHP\Task\TaskInterface;
1010
use PhpSpec\ObjectBehavior;
1111
use Prophecy\Argument;
12+
use Symfony\Component\Console\Formatter\OutputFormatter;
1213
use Symfony\Component\Console\Helper\ProgressBar;
1314
use Symfony\Component\Console\Output\OutputInterface;
1415
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1516

1617
class ProgressSubscriberSpec extends ObjectBehavior
1718
{
18-
function let(OutputInterface $output, ProgressBar $progressBar)
19+
function let(OutputInterface $output)
1920
{
21+
$output->getVerbosity()->willReturn(OutputInterface::VERBOSITY_NORMAL);
22+
$output->isDecorated()->willReturn(false);
23+
$output->getFormatter()->willReturn(new OutputFormatter());
24+
25+
$progressBar = new ProgressBar($output->getWrappedObject());
26+
2027
$this->beConstructedWith($output, $progressBar);
2128
}
2229

@@ -35,53 +42,42 @@ function it_should_subscribe_to_events()
3542
$this->getSubscribedEvents()->shouldBeArray();
3643
}
3744

38-
function it_starts_progress(ProgressBar $progressBar, RunnerEvent $event, TasksCollection $tasks)
45+
function it_starts_progress(OutputInterface $output, RunnerEvent $event, TasksCollection $tasks)
3946
{
4047
$tasks->count()->willReturn(2);
4148
$event->getTasks()->willReturn($tasks);
4249

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

4852
$this->startProgress($event);
4953
}
5054

51-
function it_should_advance_progress(ProgressBar $progressBar, TaskEvent $event, TaskInterface $task)
55+
function it_should_advance_progress(OutputInterface $output, TaskEvent $event, TaskInterface $task)
5256
{
57+
$this->beConstructedWith($output, $progress = new ProgressBar($output->getWrappedObject(), 2));
58+
5359
$event->getTask()->willReturn($task);
5460

55-
$progressBar->setFormat(Argument::type('string'))->shouldBeCalled();
56-
$progressBar->setOverwrite(false)->shouldBeCalled();
57-
$progressBar->setMessage(Argument::type('string'))->shouldBeCalled();
58-
$progressBar->advance()->shouldBeCalled();
61+
$output->writeln('')->shouldBeCalled();
62+
$output->write(Argument::containingString('Running task'))->shouldBeCalled();
63+
$output->write(Argument::containingString('1/2'))->shouldBeCalled();
5964

6065
$this->advanceProgress($event);
6166
}
6267

63-
function it_finishes_progress(OutputInterface $output, ProgressBar $progressBar, RunnerEvent $event)
68+
function it_finishes_progress(OutputInterface $output, RunnerEvent $event)
6469
{
65-
$progressBar->getProgress()->willReturn(1);
66-
$progressBar->getMaxSteps()->willReturn(1);
70+
$this->beConstructedWith($output, $progress = new ProgressBar($output->getWrappedObject(), 0));
6771

68-
$progressBar->setOverwrite(false)->shouldBeCalled();
69-
$progressBar->finish()->shouldBeCalled();
7072
$output->writeln('')->shouldBeCalled();
7173

7274
$this->finishProgress($event);
7375
}
7476

75-
function it_finishes_progress_early(OutputInterface $output, ProgressBar $progressBar, RunnerEvent $event)
77+
function it_finishes_progress_early(OutputInterface $output, RunnerEvent $event)
7678
{
77-
$progressBar->getProgress()->willReturn(1);
78-
$progressBar->getMaxSteps()->willReturn(2);
79-
80-
$progressBar->setFormat(Argument::type('string'))->shouldBeCalled();
81-
$progressBar->setMessage(Argument::type('string'))->shouldBeCalled();
82-
83-
$progressBar->setOverwrite(false)->shouldBeCalled();
84-
$progressBar->finish()->shouldBeCalled();
79+
$this->beConstructedWith($output, $progress = new ProgressBar($output->getWrappedObject(), 2));
80+
$output->write('<fg=red>Aborted ...</fg=red>')->shouldBeCalled();
8581
$output->writeln('')->shouldBeCalled();
8682

8783
$this->finishProgress($event);

src/Task/PhpStan.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33
namespace GrumPHP\Task;
44

5-
use GrumPHP\Collection\FilesCollection;
65
use GrumPHP\Runner\TaskResult;
76
use GrumPHP\Task\Context\ContextInterface;
87
use GrumPHP\Task\Context\GitPreCommitContext;
98
use GrumPHP\Task\Context\RunContext;
10-
use Symfony\Component\Finder\SplFileInfo;
119
use Symfony\Component\OptionsResolver\OptionsResolver;
12-
use Symfony\Component\Process\Process;
1310

1411
/**
1512
* PhpStan task

0 commit comments

Comments
 (0)