Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop: (24 commits)
  Fixes #6
  Code style fixes.
  Issue #6: Fix too many arguments error.
  Exclude tests form codeclimate checks.
  Revert "Update PHPUnit version", we need to support PHP 5.5
  blacklist element not needed (and no longer present)
  Update PHPUnit version
  Let's remove some cruft
  Add PHPUnit.xml file to steer code coverage report
  Token in command, will it work?
  Output file should be what codeclimate expects
  Add repo token in after_success script
  Trailing spaces
  Markdown: 80 for line length
  Fix code violations in loadTasks.php
  Fix (most) code violations in DrupalConsoleStack.php
  Fix README code violations (line length 100)
  Fix (some) code violations on DrupalConsoleStackTest.php
  Fix RoboFile.php code violations
  Fix README.md code violations
  ...
  • Loading branch information
Jelle-S committed Feb 2, 2017
2 parents 6432f8c + 083a65e commit deffc4f
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 48 deletions.
24 changes: 24 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
engines:
phpcodesniffer:
enabled: true
config:
standard: "PSR1,PSR2"
phpmd:
enabled: true
duplication:
enabled: true
config:
languages:
php:
fixme:
enabled: true
markdownlint:
enabled: true
ratings:
paths:
- "**.php"
- "**.md"
exclude_paths:
- "**/vendor/**/*"
- "**/.idea/**/*"
- "tests/"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor
composer.lock
/build
/coverage.clover
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ php:
- 5.5
install:
- composer self-update
- composer install
- composer install --dev
script:
- vendor/bin/robo test
- vendor/bin/robo test:coverage-codeclimate
addons:
code_climate:
repo_token: 3798532b8ba006dda3541198ac9e2b9b21825dc476540ee1d9397b0665f8d033
after_success:
- vendor/bin/test-reporter
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ Extension to execute Drupal Console commands in [Robo](http://robo.li/).

[![Build Status](https://travis-ci.org/digipolisgent/robo-drupal-console.svg?branch=develop)](https://travis-ci.org/digipolisgent/robo-drupal-console)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/8940f64e-cebe-46de-b670-5a89fb0388a9/mini.png)](https://insight.sensiolabs.com/projects/8940f64e-cebe-46de-b670-5a89fb0388a9)
[![Code Climate](https://codeclimate.com/github/digipolisgent/robo-drupal-console/badges/gpa.svg)](https://codeclimate.com/github/digipolisgent/robo-drupal-console)
[![Test Coverage](https://codeclimate.com/github/digipolisgent/robo-drupal-console/badges/coverage.svg)](https://codeclimate.com/github/digipolisgent/robo-drupal-console/coverage)
[![Dependency Status](https://www.versioneye.com/user/projects/585aaebacd6569002cd5bc23/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/585aaebacd6569002cd5bc23)

Created based on [Robo DrushStack](https://github.com/boedah/robo-drush). Runs Drupal Console commands in stack. You can define global options for all commands (like Drupal root and uri).
Created based on [Robo DrushStack](https://github.com/boedah/robo-drush). Runs
Drupal Console commands in stack. You can define global options for all
commands (like Drupal root and uri).

## Table of contents

Expand All @@ -32,6 +36,7 @@ Add `"digipolisgent/robo-drupal-console": "~0.1"` to your composer.json:
}
}
```

and execute `composer update`.

OR
Expand Down
5 changes: 2 additions & 3 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ public function test()
/**
* Provides test coverage for Scrutinizer
*/
public function testCoverageScrutinize()
public function testCoverageCodeclimate()
{
$this->stopOnFail(true);
$this->taskPHPUnit()
->option('disallow-test-output')
->option('report-useless-tests')
->option('strict-coverage')
->option('-d error_reporting=-1')
->option('--coverage-clover=coverage.clover')
->option('--coverage-clover=build/logs/clover.xml')
->arg('tests')
->run();
}

}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"php": ">=5.5.0"
},
"require-dev": {
"phpunit/phpunit": "~4.4"
"phpunit/phpunit": "~4.4",
"codeclimate/php-test-reporter": "dev-master"
},
"autoload": {
"psr-4": {
Expand Down
19 changes: 19 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
>
<testsuites>
<testsuite name="robo-drupal-console tests">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
59 changes: 41 additions & 18 deletions src/DrupalConsoleStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Robo\Task\CommandStack;

/**
* Runs Drupal Console commands in stack. You can use `stopOnFail()` to point that stack should be terminated on first fail.
* You can define global options for all commands (like Drupal root and uri).
* The option --yes is always set, as it makes sense in a task runner.
* Runs Drupal Console commands in stack. You can use `stopOnFail()` to point that stack should be terminated on
* first fail. You can define global options for all commands (like Drupal root and uri). The option --yes is always
* set, as it makes sense in a task runner.
*
* ``` php
* $this->taskDrupalConsoleStack()
Expand Down Expand Up @@ -44,7 +44,9 @@
class DrupalConsoleStack extends CommandStack
{

use CommandArguments;
use CommandArguments {
option as optionNoEqualSign;
}

/**
* Verbosity levels:
Expand All @@ -59,7 +61,7 @@ class DrupalConsoleStack extends CommandStack
*
* @var array
*/
protected $optionsForNextCommand = [];
protected $optionsForNextCmd = [];


/**
Expand Down Expand Up @@ -89,6 +91,27 @@ public function __construct($pathToDrupalConsole = 'drupal')
$this->executable = $pathToDrupalConsole;
}

/**
* Pass option to executable. Options are prefixed with `--` , value can be provided in second parameter.
* Option values are automatically escaped.
*
* @param string $option
* The option name.
* @param string $value
* The option value.
*
* @return $this
*/
public function option($option, $value = null)
{
if (!is_null($option) && strpos($option, '-') !== 0) {
$option = "--$option";
}
$this->arguments .= is_null($option) ? '' : " " . $option;
$this->arguments .= is_null($value) ? '' : "=" . static::escape($value);
return $this;
}

/**
* Pass an option to the executable; applies to the next command only.
*
Expand Down Expand Up @@ -116,7 +139,7 @@ protected function optionForNextCommand($name, $value = null)
*/
protected function optionsForNextCommand($options)
{
$this->optionsForNextCommand = $options + $this->optionsForNextCommand;
$this->optionsForNextCmd = $options + $this->optionsForNextCmd;

return $this;
}
Expand Down Expand Up @@ -474,7 +497,8 @@ public function getVersion()
$result = $this->executeCommand($this->executable.' --version');
$output = $result->getMessage();
$this->drupalConsoleVersion = 'unknown';
if ($result->wasSuccessful() && preg_match(
if ($result->wasSuccessful() &&
preg_match(
'#[0-9.]+#',
$output,
$matches
Expand Down Expand Up @@ -573,8 +597,8 @@ public function siteInstall($installationProfile = '')
{
return $this->drupal(
'site:install'.($installationProfile ? ' '.static::escape(
$installationProfile
) : '')
$installationProfile
) : '')
);
}

Expand Down Expand Up @@ -729,25 +753,24 @@ public function drupal($command, $assumeYes = true)
*/
protected function injectArguments($command, $assumeYes)
{
$optionsForNextCommand = '';
foreach ($this->optionsForNextCommand as $option => $value) {
$optionsForNextCommand .= ' --'.$option.(is_null(
$value
) ? '' : ' '.static::escape($value));
$optionsForNextCmd = '';
foreach ($this->optionsForNextCmd as $option => $value) {
$optionsForNextCmd .= ' --' . $option . (
is_null($value) ? '' : '=' . static::escape($value)
);
}
$cmd = $command;
if (trim($this->arguments)) {
$cmd .= $this->arguments;
}
if (trim($optionsForNextCommand)) {
$cmd .= $optionsForNextCommand;
if (trim($optionsForNextCmd)) {
$cmd .= $optionsForNextCmd;
}
if ($assumeYes) {
$cmd .= ' --yes';
}
$this->optionsForNextCommand = [];
$this->optionsForNextCmd = [];

return $cmd;
}

}
1 change: 0 additions & 1 deletion src/loadTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ protected function taskDrupalConsoleStack($pathToDrupalConsole = 'drupal')
{
return $this->task(DrupalConsoleStack::class, $pathToDrupalConsole);
}

}
Loading

0 comments on commit deffc4f

Please sign in to comment.