-
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 #40 from veewee/feature-taskcontext
Refactoring for running the tasks in different contexts
- Loading branch information
Showing
25 changed files
with
575 additions
and
170 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace spec\GrumPHP\Collection; | ||
|
||
use GrumPHP\Task\Context\ContextInterface; | ||
use GrumPHP\Task\TaskInterface; | ||
use phpDocumentor\Reflection\DocBlock\Context; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
class TasksCollectionSpec extends ObjectBehavior | ||
{ | ||
public function let(TaskInterface $task1, TaskInterface $task2) | ||
{ | ||
$this->beConstructedWith(array($task1, $task2)); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('GrumPHP\Collection\TasksCollection'); | ||
} | ||
|
||
function it_is_an_array_collection() | ||
{ | ||
$this->shouldHaveType('Doctrine\Common\Collections\ArrayCollection'); | ||
} | ||
|
||
function it_should_filter_by_context(TaskInterface $task1, TaskInterface $task2, ContextInterface $context) | ||
{ | ||
$task1->canRunInContext($context)->willReturn(true); | ||
$task2->canRunInContext($context)->willReturn(false); | ||
|
||
$result = $this->filterByContext($context); | ||
$result->shouldBeAnInstanceOf('GrumPHP\Collection\TasksCollection'); | ||
$result->count()->shouldBe(1); | ||
$tasks = $result->toArray(); | ||
$tasks[0]->shouldBe($task1); | ||
} | ||
|
||
} |
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,38 @@ | ||
<?php | ||
|
||
namespace spec\GrumPHP\Console\Helper; | ||
|
||
use GrumPHP\Configuration\GrumPHP; | ||
use GrumPHP\Console\Helper\PathsHelper; | ||
use GrumPHP\Console\Helper\TaskRunnerHelper; | ||
use GrumPHP\Exception\FailureException; | ||
use GrumPHP\Runner\TaskRunner; | ||
use GrumPHP\Task\Context\ContextInterface; | ||
use Symfony\Component\Console\Helper\HelperSet; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
class TaskRunnerHelperSpec extends ObjectBehavior | ||
{ | ||
function let(TaskRunner $taskRunner, HelperSet $helperSet, PathsHelper $pathsHelper) | ||
{ | ||
$this->beConstructedWith($taskRunner); | ||
|
||
$helperSet->get(PathsHelper::HELPER_NAME)->willreturn($pathsHelper); | ||
$this->setHelperSet($helperSet); | ||
} | ||
|
||
function it_should_return_error_code_during_exceptions(OutputInterface $output, TaskRunner $taskRunner, ContextInterface $context) | ||
{ | ||
$taskRunner->run($context)->willThrow(new FailureException()); | ||
$this->run($output, $context)->shouldReturn(TaskRunnerHelper::CODE_ERROR); | ||
} | ||
|
||
function it_should_return_success_code_during_exceptions(OutputInterface $output, TaskRunner $taskRunner, ContextInterface $context) | ||
{ | ||
$taskRunner->run($context)->shouldBeCalled(); | ||
$this->run($output, $context)->shouldReturn(TaskRunnerHelper::CODE_SUCCESS); | ||
} | ||
} |
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\Task\Context; | ||
|
||
use GrumPHP\Collection\FilesCollection; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
class GitPreCommitContextSpec extends ObjectBehavior | ||
{ | ||
function let(FilesCollection $files) | ||
{ | ||
$this->beConstructedWith($files); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('GrumPHP\Task\Context\GitPreCommitContext'); | ||
} | ||
|
||
function it_should_be_a_task_context() | ||
{ | ||
$this->shouldImplement('GrumPHP\Task\Context\ContextInterface'); | ||
} | ||
|
||
function it_should_have_files(FilesCollection $files) | ||
{ | ||
$this->getFiles()->shouldBe($files); | ||
} | ||
} |
Oops, something went wrong.