Browse Source

[Nostromo] Refactor config load

pull/1/head
Andrés Montañez 8 years ago
parent
commit
0bae8e2b1b
  1. 1
      bin/mage
  2. 8
      src/Command/AbstractCommand.php
  3. 2
      src/Command/BuiltIn/Config/DumpCommand.php
  4. 2
      src/Command/BuiltIn/Config/EnvironmentsCommand.php
  5. 2
      src/Command/BuiltIn/DeployCommand.php
  6. 2
      src/Command/BuiltIn/Releases/ListCommand.php
  7. 2
      src/Command/BuiltIn/Releases/RollbackCommand.php
  8. 13
      src/MageApplication.php
  9. 1
      tests/Command/BuiltIn/Config/DumpCommandTest.php
  10. 1
      tests/Command/BuiltIn/Config/EnvironmentsCommandTest.php
  11. 6
      tests/Command/BuiltIn/DeployCommandMiscTasksTest.php
  12. 8
      tests/Command/BuiltIn/DeployCommandMiscTest.php
  13. 10
      tests/Command/BuiltIn/DeployCommandWithReleasesTest.php
  14. 2
      tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php
  15. 7
      tests/Command/BuiltIn/Releases/ListCommandTest.php
  16. 4
      tests/Command/BuiltIn/Releases/RollbackCommandTest.php
  17. 1
      tests/Command/BuiltIn/VersionCommandTest.php
  18. 5
      tests/MageApplicationTest.php

1
bin/mage

@ -12,7 +12,6 @@ use Mage\MageApplication;
try { try {
$mage = new MageApplication('.mage.yml'); $mage = new MageApplication('.mage.yml');
$mage->configure();
$mage->run(); $mage->run();
} catch (Exception $exception) { } catch (Exception $exception) {
printf('Error: %s' . PHP_EOL, $exception->getMessage()); printf('Error: %s' . PHP_EOL, $exception->getMessage());

8
src/Command/AbstractCommand.php

@ -66,4 +66,12 @@ abstract class AbstractCommand extends Command
$utils = new Utils(); $utils = new Utils();
return $utils->getStageName($this->runtime->getStage()); return $utils->getStageName($this->runtime->getStage());
} }
/**
* Requires the configuration to be loaded
*/
protected function requireConfig()
{
$this->getApplication()->configure();
}
} }

2
src/Command/BuiltIn/Config/DumpCommand.php

@ -41,6 +41,8 @@ class DumpCommand extends AbstractCommand
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$this->requireConfig();
$output->writeln('Starting <fg=blue>Magallanes</>'); $output->writeln('Starting <fg=blue>Magallanes</>');
$output->writeln(''); $output->writeln('');

2
src/Command/BuiltIn/Config/EnvironmentsCommand.php

@ -42,6 +42,8 @@ class EnvironmentsCommand extends AbstractCommand
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$this->requireConfig();
$output->writeln('Starting <fg=blue>Magallanes</>'); $output->writeln('Starting <fg=blue>Magallanes</>');
$output->writeln(''); $output->writeln('');

2
src/Command/BuiltIn/DeployCommand.php

@ -58,6 +58,8 @@ class DeployCommand extends AbstractCommand
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$this->requireConfig();
$output->writeln('Starting <fg=blue>Magallanes</>'); $output->writeln('Starting <fg=blue>Magallanes</>');
$output->writeln(''); $output->writeln('');

2
src/Command/BuiltIn/Releases/ListCommand.php

@ -51,6 +51,8 @@ class ListCommand extends AbstractCommand
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$this->requireConfig();
$utils = new Utils(); $utils = new Utils();
$output->writeln('Starting <fg=blue>Magallanes</>'); $output->writeln('Starting <fg=blue>Magallanes</>');
$output->writeln(''); $output->writeln('');

2
src/Command/BuiltIn/Releases/RollbackCommand.php

@ -52,6 +52,8 @@ class RollbackCommand extends DeployCommand
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$this->requireConfig();
$output->writeln('Starting <fg=blue>Magallanes</>'); $output->writeln('Starting <fg=blue>Magallanes</>');
$output->writeln(''); $output->writeln('');

13
src/MageApplication.php

@ -40,9 +40,11 @@ class MageApplication extends Application
*/ */
public function __construct($file) public function __construct($file)
{ {
$this->file = $file; parent::__construct('Magallanes', Mage::VERSION);
$this->file = $file;
$dispatcher = new EventDispatcher(); $dispatcher = new EventDispatcher();
$this->setDispatcher($dispatcher);
$dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) { $dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) {
$output = $event->getOutput(); $output = $event->getOutput();
@ -52,8 +54,8 @@ class MageApplication extends Application
$event->setException(new \LogicException('Caught exception', $exitCode, $event->getException())); $event->setException(new \LogicException('Caught exception', $exitCode, $event->getException()));
}); });
$this->setDispatcher($dispatcher); $this->runtime = $this->instantiateRuntime();
parent::__construct('Magallanes', Mage::VERSION); $this->loadBuiltInCommands();
} }
/** /**
@ -85,12 +87,9 @@ class MageApplication extends Application
$logger->pushHandler(new StreamHandler($logfile)); $logger->pushHandler(new StreamHandler($logfile));
} }
$this->runtime = $this->instantiateRuntime();
$this->runtime->setConfiguration($config['magephp']); $this->runtime->setConfiguration($config['magephp']);
$this->runtime->setLogger($logger); $this->runtime->setLogger($logger);
return;
$this->loadBuiltInCommands();
return true;
} }
throw new RuntimeException(sprintf('The file "%s" does not have a valid Magallanes configuration.', $this->file)); throw new RuntimeException(sprintf('The file "%s" does not have a valid Magallanes configuration.', $this->file));

1
tests/Command/BuiltIn/Config/DumpCommandTest.php

@ -21,7 +21,6 @@ class DumpCommandTest extends TestCase
public function testConfigDumpTermination() public function testConfigDumpTermination()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/basic.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/basic.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('config:dump'); $command = $application->find('config:dump');

1
tests/Command/BuiltIn/Config/EnvironmentsCommandTest.php

@ -21,7 +21,6 @@ class EnvironmentsCommandTest extends TestCase
public function testConfigDumpTermination() public function testConfigDumpTermination()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/basic.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/basic.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('config:environments'); $command = $application->find('config:environments');

6
tests/Command/BuiltIn/DeployCommandMiscTasksTest.php

@ -21,7 +21,6 @@ class DeployCommandMiscTasksTest extends TestCase
public function testSymfonyEnvironmentConfiguration() public function testSymfonyEnvironmentConfiguration()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/symfony-envconf.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/symfony-envconf.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -54,7 +53,6 @@ class DeployCommandMiscTasksTest extends TestCase
public function testComposerFlags() public function testComposerFlags()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/composer.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/composer.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -85,7 +83,6 @@ class DeployCommandMiscTasksTest extends TestCase
public function testInvalidTaskName() public function testInvalidTaskName()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/invalid-task.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/invalid-task.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -101,7 +98,6 @@ class DeployCommandMiscTasksTest extends TestCase
public function testBrokenGitBranch() public function testBrokenGitBranch()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -120,7 +116,6 @@ class DeployCommandMiscTasksTest extends TestCase
public function testBrokenGitCheckout() public function testBrokenGitCheckout()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -139,7 +134,6 @@ class DeployCommandMiscTasksTest extends TestCase
public function testBrokenGitUpdate() public function testBrokenGitUpdate()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');

8
tests/Command/BuiltIn/DeployCommandMiscTest.php

@ -21,7 +21,6 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithNoHosts() public function testDeploymentWithNoHosts()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/no-hosts.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/no-hosts.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -40,7 +39,6 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithSudo() public function testDeploymentWithSudo()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-sudo.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-sudo.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -79,7 +77,6 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithBranchOverwrite() public function testDeploymentWithBranchOverwrite()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-without-releases.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-without-releases.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -117,8 +114,6 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithCustomTask() public function testDeploymentWithCustomTask()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-custom-task.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-custom-task.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -151,7 +146,6 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithErrorTaskCommands() public function testDeploymentWithErrorTaskCommands()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-with-error.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-with-error.yml');
$application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');
@ -193,7 +187,6 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithFailingPostDeployTaskCommands() public function testDeploymentWithFailingPostDeployTaskCommands()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-with-postdeploy-error.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-with-postdeploy-error.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -229,7 +222,6 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithSkippingTask() public function testDeploymentWithSkippingTask()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-skipping.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-skipping.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');

10
tests/Command/BuiltIn/DeployCommandWithReleasesTest.php

@ -21,7 +21,6 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentWithReleasesCommands() public function testDeploymentWithReleasesCommands()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml');
$application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');
@ -72,7 +71,6 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentWithoutReleasesTarPrepare() public function testDeploymentWithoutReleasesTarPrepare()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar1.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar1.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -88,7 +86,6 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentWithoutReleasesTarCopy() public function testDeploymentWithoutReleasesTarCopy()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar2.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar2.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -104,7 +101,6 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentWithoutReleasesTarCleanup() public function testDeploymentWithoutReleasesTarCleanup()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar3.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar3.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -120,7 +116,6 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentFailCopyCommands() public function testDeploymentFailCopyCommands()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-fail-copy-tar.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-fail-copy-tar.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -136,7 +131,6 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentWithoutReleasesForceRelease() public function testDeploymentWithoutReleasesForceRelease()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-release.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-release.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -152,7 +146,6 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentFailToExtract() public function testDeploymentFailToExtract()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml');
$application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');
@ -195,7 +188,6 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentFailToCopy() public function testDeploymentFailToCopy()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml');
$application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');
@ -237,7 +229,6 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentFailCleanup() public function testDeploymentFailCleanup()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml');
$application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');
@ -291,7 +282,6 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentFailMidway() public function testDeploymentFailMidway()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml');
$application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');

2
tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php

@ -21,7 +21,6 @@ class DeployCommandWithoutReleasesTest extends TestCase
public function testDeploymentWithoutReleasesCommands() public function testDeploymentWithoutReleasesCommands()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-without-releases.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-without-releases.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -59,7 +58,6 @@ class DeployCommandWithoutReleasesTest extends TestCase
public function testDeploymentFailMidway() public function testDeploymentFailMidway()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-without-releases.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-without-releases.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');

7
tests/Command/BuiltIn/Releases/ListCommandTest.php

@ -21,7 +21,6 @@ class ListCommandTest extends TestCase
public function testListReleasesCommands() public function testListReleasesCommands()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');
@ -49,7 +48,6 @@ class ListCommandTest extends TestCase
public function testListReleasesWithInvalidEnvironment() public function testListReleasesWithInvalidEnvironment()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');
@ -65,7 +63,6 @@ class ListCommandTest extends TestCase
public function testListReleasesWithoutReleases() public function testListReleasesWithoutReleases()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-without-releases.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-without-releases.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');
@ -81,7 +78,6 @@ class ListCommandTest extends TestCase
public function testFailToGetCurrentRelease() public function testFailToGetCurrentRelease()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-fail-get-current.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-fail-get-current.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');
@ -97,7 +93,6 @@ class ListCommandTest extends TestCase
public function testNoReleasesAvailable() public function testNoReleasesAvailable()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-no-releases.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-no-releases.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');
@ -112,7 +107,6 @@ class ListCommandTest extends TestCase
public function testFailGetReleases() public function testFailGetReleases()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-fail-get-releases.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-fail-get-releases.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');
@ -128,7 +122,6 @@ class ListCommandTest extends TestCase
public function testNoHosts() public function testNoHosts()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-no-hosts.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-no-hosts.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');

4
tests/Command/BuiltIn/Releases/RollbackCommandTest.php

@ -21,7 +21,6 @@ class RollbackCommandTest extends TestCase
public function testRollbackReleaseCommands() public function testRollbackReleaseCommands()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:rollback'); $command = $application->find('releases:rollback');
@ -49,7 +48,6 @@ class RollbackCommandTest extends TestCase
public function testRollbackReleaseWithInvalidEnvironment() public function testRollbackReleaseWithInvalidEnvironment()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:rollback'); $command = $application->find('releases:rollback');
@ -65,7 +63,6 @@ class RollbackCommandTest extends TestCase
public function testRollbackReleaseWithoutReleases() public function testRollbackReleaseWithoutReleases()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-without-releases.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-without-releases.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:rollback'); $command = $application->find('releases:rollback');
@ -81,7 +78,6 @@ class RollbackCommandTest extends TestCase
public function testRollbackReleaseNotAvailable() public function testRollbackReleaseNotAvailable()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-not-have-release.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-not-have-release.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:rollback'); $command = $application->find('releases:rollback');

1
tests/Command/BuiltIn/VersionCommandTest.php

@ -22,7 +22,6 @@ class VersionCommandTest extends TestCase
public function testVersionOutput() public function testVersionOutput()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/basic.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/basic.yml');
$application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('version'); $command = $application->find('version');

5
tests/MageApplicationTest.php

@ -21,7 +21,6 @@ class MageApplicationTest extends TestCase
public function testValidConfiguration() public function testValidConfiguration()
{ {
$application = new MageApplication(__DIR__ . '/Resources/basic.yml'); $application = new MageApplication(__DIR__ . '/Resources/basic.yml');
$application->configure();
$this->assertTrue($application instanceof MageApplication); $this->assertTrue($application instanceof MageApplication);
} }
@ -29,7 +28,6 @@ class MageApplicationTest extends TestCase
{ {
try { try {
$application = new MageApplication(__DIR__ . '/Resources/invalid.yml'); $application = new MageApplication(__DIR__ . '/Resources/invalid.yml');
$application->configure();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('The file "%s" does not have a valid Magallanes configuration.', __DIR__ . '/Resources/invalid.yml'), $exception->getMessage()); $this->assertEquals(sprintf('The file "%s" does not have a valid Magallanes configuration.', __DIR__ . '/Resources/invalid.yml'), $exception->getMessage());
@ -40,7 +38,6 @@ class MageApplicationTest extends TestCase
{ {
try { try {
$application = new MageApplication(__DIR__ . '/Resources/invalid-yaml.yml'); $application = new MageApplication(__DIR__ . '/Resources/invalid-yaml.yml');
$application->configure();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('Error parsing the file "%s".', __DIR__ . '/Resources/invalid-yaml.yml'), $exception->getMessage()); $this->assertEquals(sprintf('Error parsing the file "%s".', __DIR__ . '/Resources/invalid-yaml.yml'), $exception->getMessage());
@ -51,7 +48,6 @@ class MageApplicationTest extends TestCase
{ {
try { try {
$application = new MageApplication(__DIR__ . '/Resources/this-does-not-exists.yml'); $application = new MageApplication(__DIR__ . '/Resources/this-does-not-exists.yml');
$application->configure();
} catch (Exception $exception) { } catch (Exception $exception) {
$this->assertTrue($exception instanceof RuntimeException); $this->assertTrue($exception instanceof RuntimeException);
$this->assertEquals(sprintf('The file "%s" does not exists or is not readable.', __DIR__ . '/Resources/this-does-not-exists.yml'), $exception->getMessage()); $this->assertEquals(sprintf('The file "%s" does not exists or is not readable.', __DIR__ . '/Resources/this-does-not-exists.yml'), $exception->getMessage());
@ -62,7 +58,6 @@ class MageApplicationTest extends TestCase
{ {
$application = new MageApplication(__DIR__ . '/Resources/basic.yml'); $application = new MageApplication(__DIR__ . '/Resources/basic.yml');
$application->setAutoExit(false); $application->setAutoExit(false);
$application->configure();
$this->assertTrue($application instanceof MageApplication); $this->assertTrue($application instanceof MageApplication);
$application->register('foo')->setCode(function () { $application->register('foo')->setCode(function () {

Loading…
Cancel
Save