Skip to content

Commit

Permalink
Merge pull request #701 from veewee/fix-tests-and-upgrade
Browse files Browse the repository at this point in the history
Add support symfony 5, add support php74, drop support php71
  • Loading branch information
veewee authored Nov 29, 2019
2 parents 9fc00eb + e20d45b commit 122571d
Show file tree
Hide file tree
Showing 32 changed files with 333 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: php

php:
- 7.1
- 7.2
- 7.3
- 7.4snapshot
- nightly

env:
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ platform:

environment:
matrix:
- dependencies: highest
php_version: 7.1
- dependencies: highest
php_version: 7.2
- dependencies: highest
php_version: 7.3
- dependencies: highest
php_version: 7.4

project_directory: c:\projects\grumphp
composer_directory: c:\tools\composer
Expand Down
40 changes: 20 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@
}
],
"require": {
"php": "^7.1",
"php": "^7.2",
"ext-json": "*",
"composer-plugin-api": "~1.0",
"doctrine/collections": "~1.2",
"gitonomy/gitlib": "^1.0.3",
"monolog/monolog": "~1.16 || ^2.0",
"seld/jsonlint": "~1.1",
"symfony/config": "~3.4 || ~4.0",
"symfony/console": "~3.4 || ~4.0",
"symfony/dependency-injection": "~3.4 || ~4.0",
"symfony/event-dispatcher": "~3.4 || ~4.0",
"symfony/filesystem": "~3.4 || ~4.0",
"symfony/finder": "~3.4 || ~4.0",
"symfony/options-resolver": "~3.4 || ~4.0",
"symfony/process": "~3.4 || ~4.0",
"symfony/yaml": "~3.4 || ~4.0"
"symfony/config": "~3.4 || ~4.0 || ~5.0",
"symfony/console": "~3.4 || ~4.0 || ~5.0",
"symfony/dependency-injection": "~3.4 || ~4.0 || ~5.0",
"symfony/event-dispatcher": "~3.4 || ~4.0 || ~5.0",
"symfony/filesystem": "~3.4 || ~4.0 || ~5.0",
"symfony/finder": "~3.4 || ~4.0 || ~5.0",
"symfony/options-resolver": "~3.4 || ~4.0 || ~5.0",
"symfony/process": "~3.4 || ~4.0 || ~5.0",
"symfony/yaml": "~3.4 || ~4.0 || ~5.0"
},
"require-dev": {
"brianium/paratest": "^2.2.0",
"composer/composer": "^1.8.5",
"friendsofphp/php-cs-fixer": "~2",
"jakub-onderka/php-parallel-lint": "^0.9.2",
"localheinz/composer-normalize": "^1.2",
"nikic/php-parser": "^3.0",
"phpspec/phpspec": "^5.1",
"phpunit/phpunit": "^7.5.12",
"sensiolabs/security-checker": "^5.0",
"squizlabs/php_codesniffer": "~2.9"
"brianium/paratest": "~3.1",
"composer/composer": "~1.9",
"friendsofphp/php-cs-fixer": "~2.16",
"jakub-onderka/php-parallel-lint": "~1.0",
"localheinz/composer-normalize": "~1.3",
"nikic/php-parser": "~3.1",
"phpspec/phpspec": "~6.1",
"phpunit/phpunit": "^7.5.17",
"sensiolabs/security-checker": "~6.0",
"squizlabs/php_codesniffer": "~3.5"
},
"suggest": {
"atoum/atoum": "Lets GrumPHP run your unit tests.",
Expand Down
3 changes: 3 additions & 0 deletions grumphp.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ parameters:
- "#test/(.*).yml#"
phplint: ~
phpparser:
ignore_patterns:
- '#src/Event/Event.php#'
- '#test/Symfony/(.*)#'
visitors:
no_exit_statements: ~
never_use_else: ~
Expand Down
4 changes: 2 additions & 2 deletions resources/config/console.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
GrumPHP\Console\Application:
class: Symfony\Component\Console\Application
calls:
- { method: 'setDispatcher', arguments: ['@event_dispatcher'] }
- { method: 'setDispatcher', arguments: ['@Symfony\Component\EventDispatcher\EventDispatcher'] }
- { method: 'setCommandLoader', arguments: ['@console.command_loader'] }
configurator: ['@GrumPHP\Console\ApplicationConfigurator', 'configure']
public: true
Expand Down Expand Up @@ -66,7 +66,7 @@ services:
arguments:
- '@config'
- '@task_runner'
- '@event_dispatcher'
- '@Symfony\Component\EventDispatcher\EventDispatcher'
- '@GrumPHP\Locator\AsciiLocator'
tags:
- { name: 'console.helper' }
11 changes: 5 additions & 6 deletions resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ services:
synthetic: true
public: true

event_dispatcher:
class: Symfony\Component\EventDispatcher\EventDispatcherInterface
factory: GrumPHP\Event\EventDispatcherFactory::create
Symfony\Component\EventDispatcher\EventDispatcher: ~
GrumPHP\Event\Dispatcher\Bridge\SymfonyEventDispatcher:
arguments:
- '@service_container'
public: true
- '@Symfony\Component\EventDispatcher\EventDispatcher'
GrumPHP\Event\Dispatcher\EventDispatcherInterface: '@GrumPHP\Event\Dispatcher\Bridge\SymfonyEventDispatcher'

filesystem:
alias: grumphp.util.filesystem
Expand Down Expand Up @@ -52,7 +51,7 @@ services:
class: GrumPHP\Runner\TaskRunner
arguments:
- '@config'
- '@event_dispatcher'
- '@GrumPHP\Event\Dispatcher\EventDispatcherInterface'
public: true

grumphp.io:
Expand Down
1 change: 1 addition & 0 deletions resources/config/util.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ services:
'7.1': '2019-12-01 23:59:59'
'7.2': '2020-11-30 23:59:59'
'7.3': '2021-12-06 23:59:59'
'7.4': '2022-11-28 23:59:59'
7 changes: 3 additions & 4 deletions spec/Console/Helper/TaskRunnerHelperSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
use GrumPHP\Task\Context\ContextInterface;
use GrumPHP\Task\TaskInterface;
use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

Expand All @@ -25,7 +24,7 @@ class TaskRunnerHelperSpec extends ObjectBehavior
function let(
GrumPHP $config,
TaskRunner $taskRunner,
EventDispatcherInterface $eventDispatcher,
EventDispatcher $eventDispatcher,
AsciiLocator $asciiLocator,
TaskRunnerContext $runnerContext,
ContextInterface $taskContext
Expand Down Expand Up @@ -126,7 +125,7 @@ function it_should_add_a_progress_listener_during_run(
OutputInterface $output,
TaskRunner $taskRunner,
TaskRunnerContext $runnerContext,
EventDispatcherInterface $eventDispatcher
EventDispatcher $eventDispatcher
) {
$taskRunner->run($runnerContext)->willReturn(new TaskResultCollection());
$eventDispatcher->addSubscriber(Argument::type(ProgressSubscriber::class))->shouldBeCalled();
Expand Down
37 changes: 0 additions & 37 deletions spec/Event/EventDispatcherFactorySpec.php

This file was deleted.

2 changes: 1 addition & 1 deletion spec/Event/RunnerEventSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use GrumPHP\Collection\TaskResultCollection;
use GrumPHP\Collection\TasksCollection;
use GrumPHP\Event\Event;
use GrumPHP\Event\RunnerEvent;
use GrumPHP\Task\Context\ContextInterface;
use PhpSpec\ObjectBehavior;
use Symfony\Component\EventDispatcher\Event;

class RunnerEventSpec extends ObjectBehavior
{
Expand Down
13 changes: 4 additions & 9 deletions spec/Event/Subscriber/ProgressSubscriberSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
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;

Expand All @@ -22,9 +21,7 @@ function let(OutputInterface $output)
$output->isDecorated()->willReturn(false);
$output->getFormatter()->willReturn(new OutputFormatter());

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

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

function it_is_initializable()
Expand Down Expand Up @@ -54,32 +51,30 @@ function it_starts_progress(OutputInterface $output, RunnerEvent $event, TasksCo

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

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

$output->writeln('')->willReturn(null);
$output->write(Argument::containingString('Running task'))->shouldBeCalled();
$output->write(Argument::containingString('1/2'))->shouldBeCalled();

$this->createProgressBar(2);
$this->advanceProgress($event);
}

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

$output->writeln('')->shouldBeCalled();

$this->createProgressBar(0);
$this->finishProgress($event);
}

function it_finishes_progress_early(OutputInterface $output, RunnerEvent $event)
{
$this->beConstructedWith($output, $progress = new ProgressBar($output->getWrappedObject(), 2));
$output->write(Argument::containingString('<fg=red>Aborted ...</fg=red>'))->shouldBeCalled();
$output->writeln('')->shouldBeCalled();

$this->createProgressBar(2);
$this->finishProgress($event);
}
}
2 changes: 1 addition & 1 deletion spec/Event/TaskEventSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace spec\GrumPHP\Event;

use GrumPHP\Event\Event;
use GrumPHP\Event\TaskEvent;
use GrumPHP\Task\Context\ContextInterface;
use GrumPHP\Task\TaskInterface;
use PhpSpec\ObjectBehavior;
use Symfony\Component\EventDispatcher\Event;

class TaskEventSpec extends ObjectBehavior
{
Expand Down
18 changes: 9 additions & 9 deletions spec/Runner/TaskRunnerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GrumPHP\Collection\TaskResultCollection;
use GrumPHP\Configuration\GrumPHP;
use GrumPHP\Event\Dispatcher\EventDispatcherInterface;
use GrumPHP\Event\RunnerEvent;
use GrumPHP\Event\RunnerEvents;
use GrumPHP\Event\RunnerFailedEvent;
Expand All @@ -19,7 +20,6 @@
use GrumPHP\Task\TaskInterface;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class TaskRunnerSpec extends ObjectBehavior
{
Expand Down Expand Up @@ -210,10 +210,10 @@ function it_triggers_events_during_happy_flow(
$task1->run($taskContext)->shouldBeCalled();
$task2->run($taskContext)->shouldBeCalled();

$eventDispatcher->dispatch(RunnerEvents::RUNNER_RUN, Argument::type(RunnerEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(TaskEvents::TASK_RUN, Argument::type(TaskEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(TaskEvents::TASK_COMPLETE, Argument::type(TaskEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(RunnerEvents::RUNNER_COMPLETE, Argument::type(RunnerEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(RunnerEvent::class), RunnerEvents::RUNNER_RUN)->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(TaskEvent::class), TaskEvents::TASK_RUN)->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(TaskEvent::class), TaskEvents::TASK_COMPLETE)->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(RunnerEvent::class), RunnerEvents::RUNNER_COMPLETE)->shouldBeCalled();

$this->run($runnerContext);
}
Expand All @@ -228,10 +228,10 @@ function it_triggers_events_during_error_flow(
$task1->run($taskContext)->willReturn(TaskResult::createFailed($task1->getWrappedObject(), $taskContext->getWrappedObject(), ''));
$task2->run($taskContext)->willReturn(TaskResult::createFailed($task1->getWrappedObject(), $taskContext->getWrappedObject(), ''));

$eventDispatcher->dispatch(RunnerEvents::RUNNER_RUN, Argument::type(RunnerEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(TaskEvents::TASK_RUN, Argument::type(TaskEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(TaskEvents::TASK_FAILED, Argument::type(TaskFailedEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(RunnerEvents::RUNNER_FAILED, Argument::type(RunnerFailedEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(RunnerEvent::class), RunnerEvents::RUNNER_RUN)->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(TaskEvent::class), TaskEvents::TASK_RUN)->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(TaskFailedEvent::class), TaskEvents::TASK_FAILED)->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(RunnerFailedEvent::class), RunnerEvents::RUNNER_FAILED)->shouldBeCalled();

$this->run($runnerContext);
}
Expand Down
10 changes: 6 additions & 4 deletions src/Console/Command/ConfigureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function configure(): void
/**
* @return int|void
*/
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $input, OutputInterface $output): int
{
$this->input = $input;

Expand All @@ -75,28 +75,30 @@ public function execute(InputInterface $input, OutputInterface $output)
$output->writeln('<fg=yellow>GrumPHP is already configured!</fg=yellow>');
}

return;
return 0;
}

// Check configuration:
$configuration = $this->buildConfiguration($input, $output);
if (!$configuration) {
$output->writeln('<fg=yellow>Skipped configuring GrumPHP. Using default configuration.</fg=yellow>');

return;
return 0;
}

// Check write action
$written = $this->writeConfiguration($configuration);
if (!$written) {
$output->writeln('<fg=red>The configuration file could not be saved. Give me some permissions!</fg=red>');

return;
return 1;
}

if ($input->isInteractive()) {
$output->writeln('<fg=green>GrumPHP is configured and ready to kick ass!</fg=green>');
}

return 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/Git/CommitMsgCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function configure(): void
/**
* @return int|void
*/
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $input, OutputInterface $output): int
{
$io = new ConsoleIO($input, $output);
$files = $this->getCommittedFiles($io);
Expand Down
Loading

0 comments on commit 122571d

Please sign in to comment.