mirror of https://github.com/hauke68/Magallanes
Andrés Montañez
8 years ago
committed by
GitHub
30 changed files with 686 additions and 76 deletions
@ -0,0 +1,38 @@ |
|||||||
|
<?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\Composer; |
||||||
|
|
||||||
|
use Mage\Task\AbstractTask; |
||||||
|
|
||||||
|
/** |
||||||
|
* Abstract Composer Task |
||||||
|
* |
||||||
|
* @author Andrés Montañez <andresmontanez@gmail.com> |
||||||
|
*/ |
||||||
|
abstract class AbstractComposerTask extends AbstractTask |
||||||
|
{ |
||||||
|
protected function getOptions() |
||||||
|
{ |
||||||
|
$options = array_merge( |
||||||
|
['path' => 'composer'], |
||||||
|
$this->getComposerOptions(), |
||||||
|
$this->runtime->getMergedOption('composer'), |
||||||
|
$this->options |
||||||
|
); |
||||||
|
|
||||||
|
return $options; |
||||||
|
} |
||||||
|
|
||||||
|
protected function getComposerOptions() |
||||||
|
{ |
||||||
|
return []; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
<?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\Symfony; |
||||||
|
|
||||||
|
use Mage\Task\AbstractTask; |
||||||
|
|
||||||
|
/** |
||||||
|
* Abstract Symfony Task |
||||||
|
* |
||||||
|
* @author Andrés Montañez <andresmontanez@gmail.com> |
||||||
|
*/ |
||||||
|
abstract class AbstractSymfonyTask extends AbstractTask |
||||||
|
{ |
||||||
|
protected function getOptions() |
||||||
|
{ |
||||||
|
$options = array_merge( |
||||||
|
['console' => 'bin/console', 'env' => 'dev', 'flags' => ''], |
||||||
|
$this->getSymfonyOptions(), |
||||||
|
$this->runtime->getMergedOption('symfony'), |
||||||
|
$this->options |
||||||
|
); |
||||||
|
|
||||||
|
return $options; |
||||||
|
} |
||||||
|
|
||||||
|
protected function getSymfonyOptions() |
||||||
|
{ |
||||||
|
return []; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
magephp: |
||||||
|
environments: |
||||||
|
production: |
||||||
|
user: app |
||||||
|
host_path: /var/www/myapp |
||||||
|
hosts: |
||||||
|
- webserver |
||||||
|
pre-deploy: |
||||||
|
on-deploy: |
||||||
|
- custom-invalid-class |
||||||
|
post-deploy: |
||||||
|
custom_tasks: |
||||||
|
- Mage\Tests\Task\Custom\InvalidClass |
@ -0,0 +1,13 @@ |
|||||||
|
magephp: |
||||||
|
environments: |
||||||
|
production: |
||||||
|
user: app |
||||||
|
host_path: /var/www/myapp |
||||||
|
hosts: |
||||||
|
- webserver |
||||||
|
pre-deploy: |
||||||
|
on-deploy: |
||||||
|
- custom-invalid-inheritance |
||||||
|
post-deploy: |
||||||
|
custom_tasks: |
||||||
|
- Mage\Tests\Task\Custom\InvalidInheritanceTask |
@ -0,0 +1,13 @@ |
|||||||
|
magephp: |
||||||
|
environments: |
||||||
|
production: |
||||||
|
user: app |
||||||
|
host_path: /var/www/myapp |
||||||
|
hosts: |
||||||
|
- webserver |
||||||
|
pre-deploy: |
||||||
|
on-deploy: |
||||||
|
- custom-not-instantiable |
||||||
|
post-deploy: |
||||||
|
custom_tasks: |
||||||
|
- Mage\Tests\Task\Custom\NotInstantiableTask |
@ -0,0 +1,13 @@ |
|||||||
|
magephp: |
||||||
|
environments: |
||||||
|
production: |
||||||
|
user: app |
||||||
|
host_path: /var/www/myapp |
||||||
|
hosts: |
||||||
|
- webserver |
||||||
|
pre-deploy: |
||||||
|
on-deploy: |
||||||
|
- custom-valid |
||||||
|
post-deploy: |
||||||
|
custom_tasks: |
||||||
|
- Mage\Tests\Task\Custom\ValidTask |
@ -0,0 +1,17 @@ |
|||||||
|
magephp: |
||||||
|
log_dir: /tmp |
||||||
|
composer: |
||||||
|
path: /usr/bin/composer.phar |
||||||
|
exclude: |
||||||
|
- ./var/cache/* |
||||||
|
- ./var/log/* |
||||||
|
- ./web/app_dev.php |
||||||
|
environments: |
||||||
|
test: |
||||||
|
user: tester |
||||||
|
host_path: /var/www/test |
||||||
|
hosts: |
||||||
|
- testhost |
||||||
|
pre-deploy: |
||||||
|
- composer/install: { flags: '--prefer-source' } |
||||||
|
- composer/dump-autoload: { flags: '--no-scripts' } |
@ -0,0 +1,28 @@ |
|||||||
|
magephp: |
||||||
|
log_dir: /tmp |
||||||
|
environments: |
||||||
|
test: |
||||||
|
user: tester |
||||||
|
branch: test |
||||||
|
from: ./dist |
||||||
|
host_path: /var/www/test |
||||||
|
releases: 4 |
||||||
|
exclude: |
||||||
|
- ./var/cache/* |
||||||
|
- ./var/log/* |
||||||
|
- ./web/app_dev.php |
||||||
|
- |
||||||
|
- |
||||||
|
hosts: |
||||||
|
- testhost |
||||||
|
pre-deploy: |
||||||
|
- git/update |
||||||
|
- composer/install |
||||||
|
- composer/dump-autoload |
||||||
|
on-deploy: |
||||||
|
- symfony/cache-warmup: { env: 'dev' } |
||||||
|
- symfony/assets-install: { env: 'dev' } |
||||||
|
- symfony/assetic-dump: { env: 'dev' } |
||||||
|
on-release: |
||||||
|
post-release: |
||||||
|
post-deploy: |
@ -0,0 +1,25 @@ |
|||||||
|
magephp: |
||||||
|
log_dir: /tmp |
||||||
|
environments: |
||||||
|
test: |
||||||
|
user: tester |
||||||
|
branch: test |
||||||
|
from: ./dist |
||||||
|
host_path: /var/www/test |
||||||
|
exclude: |
||||||
|
- ./var/cache/* |
||||||
|
- ./var/log/* |
||||||
|
- ./web/app_dev.php |
||||||
|
hosts: |
||||||
|
- testhost |
||||||
|
pre-deploy: |
||||||
|
- git/update |
||||||
|
- composer/install |
||||||
|
- composer/dump-autoload |
||||||
|
on-deploy: |
||||||
|
- symfony/cache-warmup: { env: 'dev' } |
||||||
|
- symfony/assets-install: { env: 'dev' } |
||||||
|
- symfony/assetic-dump: { env: 'dev' } |
||||||
|
on-release: |
||||||
|
post-release: |
||||||
|
post-deploy: |
@ -0,0 +1,43 @@ |
|||||||
|
<?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\Composer; |
||||||
|
|
||||||
|
use Mage\Task\BuiltIn\Composer\AbstractComposerTask; |
||||||
|
use Symfony\Component\Process\Process; |
||||||
|
|
||||||
|
/** |
||||||
|
* Basic Composer Task |
||||||
|
* |
||||||
|
* @author Andrés Montañez <andresmontanez@gmail.com> |
||||||
|
*/ |
||||||
|
class BasicComposerTask extends AbstractComposerTask |
||||||
|
{ |
||||||
|
public function getName() |
||||||
|
{ |
||||||
|
return 'composer/help'; |
||||||
|
} |
||||||
|
|
||||||
|
public function getDescription() |
||||||
|
{ |
||||||
|
return '[Composer] Help'; |
||||||
|
} |
||||||
|
|
||||||
|
public function execute() |
||||||
|
{ |
||||||
|
$options = $this->getOptions(); |
||||||
|
$cmd = sprintf('%s help', $options['path']); |
||||||
|
|
||||||
|
/** @var Process $process */ |
||||||
|
$process = $this->runtime->runCommand(trim($cmd)); |
||||||
|
|
||||||
|
return $process->isSuccessful(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Mage\Tests\Task\BuiltIn\Composer; |
||||||
|
|
||||||
|
use Mage\Tests\Runtime\RuntimeMockup; |
||||||
|
use PHPUnit_Framework_TestCase as TestCase; |
||||||
|
|
||||||
|
class BasicComposerTaskTest extends TestCase |
||||||
|
{ |
||||||
|
public function testBasicTask() |
||||||
|
{ |
||||||
|
$runtime = new RuntimeMockup(); |
||||||
|
$runtime->setConfiguration(['environments' => ['test' => []]]); |
||||||
|
$runtime->setEnvironment('test'); |
||||||
|
|
||||||
|
$task = new BasicComposerTask(); |
||||||
|
$task->setRuntime($runtime); |
||||||
|
$this->assertEquals('[Composer] Help', $task->getDescription()); |
||||||
|
|
||||||
|
$task->execute(); |
||||||
|
|
||||||
|
$ranCommands = $runtime->getRanCommands(); |
||||||
|
$testCase = array( |
||||||
|
0 => 'composer help', |
||||||
|
); |
||||||
|
|
||||||
|
// Check total of Executed Commands |
||||||
|
$this->assertEquals(count($testCase), count($ranCommands)); |
||||||
|
|
||||||
|
// Check Generated Commands |
||||||
|
foreach ($testCase as $index => $command) { |
||||||
|
$this->assertEquals($command, $ranCommands[$index]); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
<?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\Custom; |
||||||
|
|
||||||
|
use Symfony\Component\Process\Process; |
||||||
|
|
||||||
|
/** |
||||||
|
* Custom PreRegistered Task for Testing |
||||||
|
* |
||||||
|
* @author Andrés Montañez <andresmontanez@gmail.com> |
||||||
|
*/ |
||||||
|
class InvalidInheritanceTask |
||||||
|
{ |
||||||
|
/** |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getName() |
||||||
|
{ |
||||||
|
return 'custom-invalid-inheritance'; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getDescription() |
||||||
|
{ |
||||||
|
return '[Custom] Invalid Inheritance*'; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function execute() |
||||||
|
{ |
||||||
|
/** @var Process $process */ |
||||||
|
$process = $this->runtime->runCommand('echo "custom-invalid-inheritance"'); |
||||||
|
return $process->isSuccessful(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
<?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\Custom; |
||||||
|
|
||||||
|
use Mage\Task\AbstractTask; |
||||||
|
use Symfony\Component\Process\Process; |
||||||
|
|
||||||
|
/** |
||||||
|
* Custom PreRegistered Task for Testing |
||||||
|
* |
||||||
|
* @author Andrés Montañez <andresmontanez@gmail.com> |
||||||
|
*/ |
||||||
|
abstract class NotInstantiableTask extends AbstractTask |
||||||
|
{ |
||||||
|
/** |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getName() |
||||||
|
{ |
||||||
|
return 'custom-not-instantiable'; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getDescription() |
||||||
|
{ |
||||||
|
return '[Custom] Not Instantiable*'; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function execute() |
||||||
|
{ |
||||||
|
/** @var Process $process */ |
||||||
|
$process = $this->runtime->runCommand('echo "custom-not-instantiable"'); |
||||||
|
return $process->isSuccessful(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
<?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\Custom; |
||||||
|
|
||||||
|
use Mage\Task\AbstractTask; |
||||||
|
use Symfony\Component\Process\Process; |
||||||
|
|
||||||
|
/** |
||||||
|
* Custom PreRegistered Task for Testing |
||||||
|
* |
||||||
|
* @author Andrés Montañez <andresmontanez@gmail.com> |
||||||
|
*/ |
||||||
|
class ValidTask extends AbstractTask |
||||||
|
{ |
||||||
|
/** |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getName() |
||||||
|
{ |
||||||
|
return 'custom-valid'; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getDescription() |
||||||
|
{ |
||||||
|
return '[Custom] Valid*'; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function execute() |
||||||
|
{ |
||||||
|
/** @var Process $process */ |
||||||
|
$process = $this->runtime->runCommand('echo "custom-valid"'); |
||||||
|
return $process->isSuccessful(); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue