-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from veewee/feature-progressbar
- Loading branch information
Showing
39 changed files
with
933 additions
and
31 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
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,30 @@ | ||
<?php | ||
|
||
namespace spec\GrumPHP\Event; | ||
|
||
use GrumPHP\Collection\TasksCollection; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
class RunnerEventSpec extends ObjectBehavior | ||
{ | ||
function let(TasksCollection $tasks) | ||
{ | ||
$this->beConstructedWith($tasks); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('GrumPHP\Event\RunnerEvent'); | ||
} | ||
|
||
function it_is_an_event() | ||
{ | ||
$this->shouldHaveType('Symfony\Component\EventDispatcher\Event'); | ||
} | ||
|
||
function it_has_tasks(TasksCollection $tasks) | ||
{ | ||
$this->getTasks()->shouldBe($tasks); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
namespace spec\GrumPHP\Event; | ||
|
||
use GrumPHP\Collection\TasksCollection; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
class RunnerFailedEventSpec extends ObjectBehavior | ||
{ | ||
function let(TasksCollection $tasks) | ||
{ | ||
$this->beConstructedWith($tasks, array()); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('GrumPHP\Event\RunnerFailedEvent'); | ||
} | ||
|
||
function it_is_a_runner_event() | ||
{ | ||
$this->shouldHaveType('GrumPHP\Event\RunnerEvent'); | ||
} | ||
|
||
function it_has_tasks(TasksCollection $tasks) | ||
{ | ||
$this->getTasks()->shouldBe($tasks); | ||
} | ||
|
||
function it_should_contain_the_error_messages() | ||
{ | ||
$this->getMessages()->shouldBe(array()); | ||
} | ||
} |
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,69 @@ | ||
<?php | ||
|
||
namespace spec\GrumPHP\Event\Subscriber; | ||
|
||
use GrumPHP\Collection\TasksCollection; | ||
use GrumPHP\Event\RunnerEvent; | ||
use GrumPHP\Event\TaskEvent; | ||
use GrumPHP\Task\TaskInterface; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
use Symfony\Component\Console\Helper\ProgressBar; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class ProgressSubscriberSpec extends ObjectBehavior | ||
{ | ||
function let(OutputInterface $output, ProgressBar $progressBar) | ||
{ | ||
$this->beConstructedWith($output, $progressBar); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('GrumPHP\Event\Subscriber\ProgressSubscriber'); | ||
} | ||
|
||
function it_is_an_event_subscriber() | ||
{ | ||
$this->shouldImplement('Symfony\Component\EventDispatcher\EventSubscriberInterface'); | ||
} | ||
|
||
function it_should_subscribe_to_events() | ||
{ | ||
$this->getSubscribedEvents()->shouldBeArray(); | ||
} | ||
|
||
function it_starts_progress(ProgressBar $progressBar, 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(); | ||
|
||
$this->startProgress($event); | ||
} | ||
|
||
function it_should_advance_progress(ProgressBar $progressBar, TaskEvent $event, TaskInterface $task) | ||
{ | ||
$event->getTask()->willReturn($task); | ||
|
||
$progressBar->setFormat(Argument::type('string'))->shouldBeCalled(); | ||
$progressBar->setOverwrite(false)->shouldBeCalled(); | ||
$progressBar->setMessage(Argument::type('string'))->shouldBeCalled(); | ||
$progressBar->advance()->shouldBeCalled(); | ||
|
||
$this->advanceProgress($event); | ||
} | ||
|
||
function it_finishes_progress(OutputInterface $output, ProgressBar $progressBar, RunnerEvent $event) | ||
{ | ||
$progressBar->setOverwrite(false)->shouldBeCalled(); | ||
$progressBar->finish()->shouldBeCalled(); | ||
$output->writeln('')->shouldBeCalled(); | ||
|
||
$this->finishProgress($event); | ||
} | ||
} |
Oops, something went wrong.