Skip to content

Commit

Permalink
Symfony 3 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Dec 2, 2015
1 parent 8d3934a commit bc3f86e
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 85 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ language: php
matrix:
include:
- php: 5.3
- php: 5.3
env: DEPENDENCIES='low'
- php: 5.4
- php: 5.5
- php: 5.6
- php: 5.6
env: DEPENDENCIES='low'
- php: 7.0
- php: hhvm
fast_finish: true

before_install:
- composer selfupdate
- bash -c 'if [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then wget https://github.com/digitalkaoz/typehint-to-docblock/releases/download/0.2.2/typehint-to-docblock.phar && php typehint-to-docblock.phar transform spec; fi;'

install:
- composer update --prefer-dist --no-scripts --no-interaction
- if [ "$DEPENDENCIES" != "low" ]; then composer update --prefer-dist --no-scripts --no-interaction; fi;
- if [ "$DEPENDENCIES" == "low" ]; then composer update --prefer-lowest --no-scripts --no-interaction; fi;


script:
- ./bin/grumphp run
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ services:
task.myCustomTask:
class: My\Custom\Task
arguments:
- @config
- '@config'
tags:
- {name: grumphp.task, config: myConfigKey}
```
Expand Down
23 changes: 11 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@
"require": {
"php": ">=5.3.6",
"composer-plugin-api": "~1.0",
"symfony/console": "^2.5",
"symfony/expression-language": "^2.4",
"symfony/event-dispatcher": "^2.5",
"symfony/process": "^2.4",
"symfony/filesystem": "^2.4",
"symfony/finder": "^2.4",
"symfony/yaml": "^2.4",
"symfony/dependency-injection": "^2.4",
"symfony/config": "^2.4",
"doctrine/collections": "~1.2",
"gitonomy/gitlib": "~0.1.7",
"symfony/options-resolver": "^2.3"
"symfony/config": "~2.4|~3.0",
"symfony/console": "~2.6|~3.0",
"symfony/dependency-injection": "~2.4|~3.0",
"symfony/event-dispatcher": "~2.5|~3.0",
"symfony/filesystem": "~2.4|~3.0",
"symfony/finder": "~2.4|~3.0",
"symfony/options-resolver": "~2.3|~3.0",
"symfony/process": "~2.4|~3.0",
"symfony/yaml": "~2.4|~3.0"
},
"require-dev": {
"composer/composer": "~1.0@dev",
"phpspec/phpspec": "~2.1",
"composer/composer": "^1.0-alpha11",
"phpspec/phpspec": "~2.4",
"squizlabs/php_codesniffer": "~2.3",
"roave/security-advisories": "dev-master@dev",
"fabpot/php-cs-fixer": "~1.0"
Expand Down
50 changes: 27 additions & 23 deletions resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ parameters:
succeeded: grumphp-happy.txt

services:

config:
class: GrumPHP\Configuration\GrumPHP
arguments: [@service_container]
arguments:
- '@service_container'

event_dispatcher:
class: Symfony\Component\EventDispatcher\EventDispatcher
Expand All @@ -24,89 +24,93 @@ services:
process_builder:
class: GrumPHP\Process\ProcessBuilder
arguments:
- @locator.external_command
- '@locator.external_command'

git.repository:
class: Gitonomy\Git\Repository
arguments:
- %git_dir%
- '%git_dir%'

task_runner:
class: GrumPHP\Runner\TaskRunner
arguments:
- @event_dispatcher
- '@event_dispatcher'

locator.external_command:
class: GrumPHP\Locator\ExternalCommand
arguments: [%bin_dir%, @executable_finder]
arguments:
- '%bin_dir%'
- '@executable_finder'

locator.changed_files:
class: GrumPHP\Locator\ChangedFiles
arguments: [@git.repository]
arguments:
- '@git.repository'

locator.registered_files:
class: GrumPHP\Locator\RegisteredFiles
arguments: [@git.repository]
arguments:
- '@git.repository'

task.phpcs:
class: GrumPHP\Task\Phpcs
arguments:
- @config
- @process_builder
- '@config'
- '@process_builder'
tags:
- {name: grumphp.task, config: phpcs}

task.phpcsfixer:
class: GrumPHP\Task\Phpcsfixer
arguments:
- @config
- @process_builder
- '@config'
- '@process_builder'
tags:
- {name: grumphp.task, config: phpcsfixer}

task.phpspec:
class: GrumPHP\Task\Phpspec
arguments:
- @config
- @process_builder
- '@config'
- '@process_builder'
tags:
- {name: grumphp.task, config: phpspec}

task.phpunit:
class: GrumPHP\Task\Phpunit
arguments:
- @config
- @process_builder
- '@config'
- '@process_builder'
tags:
- {name: grumphp.task, config: phpunit}

task.behat:
class: GrumPHP\Task\Behat
arguments:
- @config
- @process_builder
- '@config'
- '@process_builder'
tags:
- {name: grumphp.task, config: behat}

task.git.blacklist:
class: GrumPHP\Task\Git\Blacklist
arguments:
- @config
- @process_builder
- '@config'
- '@process_builder'
tags:
- {name: grumphp.task, config: git_blacklist}

task.git.commitmessage:
class: GrumPHP\Task\Git\CommitMessage
arguments:
- @config
- '@config'
tags:
- {name: grumphp.task, config: git_commit_message}

task.codeception:
class: GrumPHP\Task\Codeception
arguments:
- @config
- @process_builder
- '@config'
- '@process_builder'
tags:
- {name: grumphp.task, config: codeception}
35 changes: 27 additions & 8 deletions spec/GrumPHP/Collection/FilesCollectionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,26 @@

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use SplFileInfo;
use Symfony\Component\Finder\SplFileInfo;

class FilesCollectionSpec extends ObjectBehavior
{
public function let(SplFileInfo $file1, SplFileInfo $file2)
/**
* @var string
*/
protected $tempFile;

function let(SplFileInfo $file1, SplFileInfo $file2)
{
$this->tempFile = tempnam(sys_get_temp_dir(), 'phpspec');
$this->beConstructedWith(array($file1, $file2));
}

function letgo()
{
unlink($this->tempFile);
}

function it_is_initializable()
{
$this->shouldHaveType('GrumPHP\Collection\FilesCollection');
Expand Down Expand Up @@ -49,10 +60,10 @@ function it_should_filter_by_not_name(SplFileInfo $file1, SplFileInfo $file2)

function it_should_filter_by_path(SplFileInfo $file1, SplFileInfo $file2)
{
$file1->getPath()->willReturn('path1/file.php');
$file2->getPath()->willReturn('path2/file.png');
$file1->getRelativePathname()->willReturn('path1/file.php');
$file2->getRelativePathname()->willReturn('path2/file.png');

$result = $this->path('path1/*');
$result = $this->path('path1');
$result->shouldBeAnInstanceOf('GrumPHP\Collection\FilesCollection');
$result->count()->shouldBe(1);
$files = $result->toArray();
Expand All @@ -61,10 +72,10 @@ function it_should_filter_by_path(SplFileInfo $file1, SplFileInfo $file2)

function it_should_filter_by_not_path(SplFileInfo $file1, SplFileInfo $file2)
{
$file1->getPath()->willReturn('path1/file.php');
$file2->getPath()->willReturn('path2/file.png');
$file1->getRelativePathname()->willReturn('path1/file.php');
$file2->getRelativePathname()->willReturn('path2/file.png');

$result = $this->notPath('path2/*');
$result = $this->notPath('path2');
$result->shouldBeAnInstanceOf('GrumPHP\Collection\FilesCollection');
$result->count()->shouldBe(1);
$files = $result->toArray();
Expand All @@ -73,6 +84,10 @@ function it_should_filter_by_not_path(SplFileInfo $file1, SplFileInfo $file2)

function it_should_filter_by_size(SplFileInfo $file1, SplFileInfo $file2)
{
$file1->isFile()->willReturn(true);
$file2->isFile()->willReturn(true);
$file1->getRealPath()->willReturn($this->tempFile);
$file2->getRealPath()->willReturn($this->tempFile);
$file1->getSize()->willReturn(8 * 1024);
$file2->getSize()->willReturn(16 * 1024);

Expand All @@ -85,6 +100,10 @@ function it_should_filter_by_size(SplFileInfo $file1, SplFileInfo $file2)

function it_should_filter_by_date(SplFileInfo $file1, SplFileInfo $file2)
{
$file1->isFile()->willReturn(true);
$file2->isFile()->willReturn(true);
$file1->getRealPath()->willReturn($this->tempFile);
$file2->getRealPath()->willReturn($this->tempFile);
$file1->getMTime()->willReturn(strtotime('-4 hours'));
$file2->getMTime()->willReturn(strtotime('-5 days'));

Expand Down
53 changes: 53 additions & 0 deletions spec/GrumPHP/Util/RegexSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace spec\GrumPHP\Util;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class RegexSpec extends ObjectBehavior
{

function it_will_handle_regex_input()
{
$this->beConstructedWith('#test#');
$this->__toString()->shouldBe('#test#');
}

function it_will_handle_glob_input()
{
$this->beConstructedWith('test');
$this->__toString()->shouldBe('#^(?=[^\.])test$#');
}

function it_should_be_able_to_add_pattern_modifier_when_no_modifiers_are_available()
{
$this->beConstructedWith('#test#');
$this->addPatternModifier('m');

$this->__toString()->shouldBe('#test#m');
}

function it_should_be_able_to_add_pattern_modifier_when__modifiers_are_available()
{
$this->beConstructedWith('#test#i');
$this->addPatternModifier('m');

$this->__toString()->shouldBe('#test#im');
}

function it_should_not_add_pattern_modifier_twice()
{
$this->beConstructedWith('#test#i');
$this->addPatternModifier('i');

$this->__toString()->shouldBe('#test#i');
}

function it_should_know_which_pattern_modifiers_can_be_user()
{
$this->beConstructedWith('#test#i');
$this->shouldThrow('RuntimeException')->duringAddPatternModifier('invalid');
$this->shouldThrow('RuntimeException')->duringAddPatternModifier('a');
}
}
Loading

0 comments on commit bc3f86e

Please sign in to comment.