Skip to content

Commit

Permalink
Issue #2: Initial setup commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
ademarco committed Dec 23, 2017
1 parent ad2568b commit 626a755
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ phpunit.xml
composer.lock
behat.yml
RoboFile.php
/tests/sandbox/*
/tests/sandbox/*.yml
6 changes: 0 additions & 6 deletions config/commands/drupal.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
command:

# Drupal-related command options.
drupal:

# Global options, this will be forwarded to all commands in 'drupal:' namespace.
options:
root: ${drupal.root}
base-url: ${drupal.base-url}

# Install Drupal site.
site-install:
options:
site-name: ${drupal.site.name}
Expand Down
10 changes: 10 additions & 0 deletions config/commands/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
command:
setup:
behat:
options:
source: "behat.yml.dist"
destination: "behat.yml"
phpunit:
options:
source: "phpunit.xml.dist"
destination: "phpunit.xml"
113 changes: 113 additions & 0 deletions src/Commands/SetupCommands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

namespace EC\OpenEuropa\TaskRunner\Commands;

use EC\OpenEuropa\TaskRunner\Tasks\ReplaceConfigTokens as ReplaceConfigTokens;
use Symfony\Component\Console\Input\InputOption;

/**
* Class SetupCommands.
*
* @package EC\OpenEuropa\TaskRunner\Commands
*/
class SetupCommands extends BaseCommands
{
use ReplaceConfigTokens\loadTasks;

/**
* Setup Behat.
*
* This command will copy behat.yml.dist in behat.yml and replace
* configuration tokens with values provided in runner.yml.dist/runner.yml.
*
* For example, given the following configuration:
*
* > drupal:
* > root: build
*
* Then its token format would be: ${drupal.root}
*
* @command setup:behat
*
* @option source Source configuration file.
* @option destination Destination configuration file.
*
* @aliases setup:b,sb
*
* @param array $options
*
* @return \Robo\Contract\TaskInterface
*/
public function setupBehat(array $options = [
'source' => InputOption::VALUE_REQUIRED,
'destination' => InputOption::VALUE_REQUIRED,
])
{
return $this->taskReplaceConfigTokens($options['source'], $options['destination']);
}

/**
* Setup PHPUnit.
*
* This command will copy phpunit.xml.dist in phpunit.xml and replace
* configuration tokens with values provided in runner.yml.dist/runner.yml.
*
* For example, given the following configuration:
*
* > drupal:
* > root: build
*
* Then its token format would be: ${drupal.root}
*
* @command setup:phpunit
*
* @option source Source configuration file.
* @option destination Destination configuration file.
*
* @aliases setup:p,sp
*
* @param array $options
*
* @return \Robo\Contract\TaskInterface
*/
public function setupPhpunit(array $options = [
'source' => InputOption::VALUE_REQUIRED,
'destination' => InputOption::VALUE_REQUIRED,
])
{
return $this->taskReplaceConfigTokens($options['source'], $options['destination']);
}


/**
* Replace configuration tokens in a text file.
*
* This command will copy source file in destination file and replace
* configuration tokens with values provided in runner.yml.dist/runner.yml.
*
* For example, given the following configuration:
*
* > drupal:
* > root: build
*
* Then its token format would be: ${drupal.root}
*
* @command setup:replace
*
* @option source Source configuration file.
* @option destination Destination configuration file.
*
* @aliases setup:p,sp
*
* @param array $options
*
* @return \Robo\Contract\TaskInterface
*/
public function setupReplace(array $options = [
'source' => InputOption::VALUE_REQUIRED,
'destination' => InputOption::VALUE_REQUIRED,
])
{
return $this->taskReplaceConfigTokens($options['source'], $options['destination']);
}
}
1 change: 1 addition & 0 deletions src/TaskRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ private function createConfiguration(array $configPaths)
$configPaths = array_merge([
__DIR__.'/../config/runner.yml',
__DIR__.'/../config/commands/drupal.yml',
__DIR__.'/../config/commands/setup.yml',
], $configPaths);

return Robo::createConfiguration($configPaths);
Expand Down
3 changes: 0 additions & 3 deletions tests/AbstractTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
use EC\OpenEuropa\TaskRunner\TaskRunner;
use League\Container\ContainerAwareInterface;
use League\Container\ContainerAwareTrait;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\NullOutput;
use Robo\TaskAccessor;
use Robo\Robo;
use Robo\Collection\CollectionBuilder;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @package EC\OpenEuropa\TaskRunner\Tests
*/
class AbstractTest extends TestCase
abstract class AbstractTest extends TestCase
{

/**
Expand Down
9 changes: 1 addition & 8 deletions tests/CommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ public function testSiteInstall($command, array $config, array $expected)
*/
public function commandsDataProvider()
{
$data = [];
$finder = new Finder();
$finder->files()->name('*.yml')->in(__DIR__.'/fixtures/commands');
foreach ($finder as $file) {
$data = array_merge($data, Yaml::parse($file->getContents()));
}

return $data;
return $this->getFixtureContent('commands.yml');
}
}
File renamed without changes.

0 comments on commit 626a755

Please sign in to comment.