mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-05-04 23:13:16 +02:00
Merge c74f5b6aa7
into 5fa99c68f5
This commit is contained in:
commit
22b15748ba
44
src/Task/BuiltIn/Grunt/RunTask.php
Normal file
44
src/Task/BuiltIn/Grunt/RunTask.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Grunt;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Grunt Task - Runs grunt
|
||||
*
|
||||
* @author Benjamin Gutmann <benjamin.gutmann@bestit-online.de>
|
||||
* @author Alexander Schneider <alexanderschneider85@gmail.com>
|
||||
*/
|
||||
class RunTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'grunt/run';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Grunt] Run';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$flags = isset($this->options['flags']) ? $this->options['flags'] : '';
|
||||
$cmd = sprintf('grunt %s', $flags);
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runCommand($cmd);
|
||||
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
}
|
45
tests/Task/BuiltIn/Grunt/RunTaskTest.php
Normal file
45
tests/Task/BuiltIn/Grunt/RunTaskTest.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Tests\Task\BuiltIn\Grunt;
|
||||
|
||||
use Mage\Task\BuiltIn\Grunt\RunTask;
|
||||
use Mage\Tests\Runtime\RuntimeMockup;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
class RunTaskTest extends TestCase
|
||||
{
|
||||
public function testRunTask()
|
||||
{
|
||||
$runtime = new RuntimeMockup();
|
||||
$runtime->setConfiguration(['environments' => ['test' => []]]);
|
||||
$runtime->setEnvironment('test');
|
||||
|
||||
$task = new RunTask();
|
||||
$task->setOptions(['flags' => '--flags']);
|
||||
$task->setRuntime($runtime);
|
||||
$this->assertEquals('[Grunt] Run', $task->getDescription());
|
||||
|
||||
$task->execute();
|
||||
|
||||
$ranCommands = $runtime->getRanCommands();
|
||||
$testCase = array(
|
||||
0 => 'grunt --flags',
|
||||
);
|
||||
|
||||
// Check total of Executed Commands
|
||||
$this->assertEquals(count($testCase), count($ranCommands));
|
||||
|
||||
// Check Generated Commands
|
||||
foreach ($testCase as $index => $command) {
|
||||
$this->assertEquals($command, $ranCommands[$index]);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue