From 261015981b8f98701c5e9cc0758a046b508d0f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Fri, 14 Apr 2017 15:35:27 -0300 Subject: [PATCH] Add tests --- .../BuiltIn/Composer/BasicComposerTask.php | 43 +++++++++++++++++++ .../Composer/BasicComposerTaskTest.php | 36 ++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/Task/BuiltIn/Composer/BasicComposerTask.php create mode 100644 tests/Task/BuiltIn/Composer/BasicComposerTaskTest.php diff --git a/tests/Task/BuiltIn/Composer/BasicComposerTask.php b/tests/Task/BuiltIn/Composer/BasicComposerTask.php new file mode 100644 index 0000000..3261aef --- /dev/null +++ b/tests/Task/BuiltIn/Composer/BasicComposerTask.php @@ -0,0 +1,43 @@ + + * + * 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 + */ +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(); + } +} diff --git a/tests/Task/BuiltIn/Composer/BasicComposerTaskTest.php b/tests/Task/BuiltIn/Composer/BasicComposerTaskTest.php new file mode 100644 index 0000000..f8f63ac --- /dev/null +++ b/tests/Task/BuiltIn/Composer/BasicComposerTaskTest.php @@ -0,0 +1,36 @@ +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]); + } + } + +}