From 91da97915150417ce2c9a5b7295e6d081a168c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sun, 29 Jan 2017 18:25:02 -0300 Subject: [PATCH] [Nostromo] Refactor config --- bin/mage | 4 +- src/MageApplication.php | 22 +++++----- .../BuiltIn/Config/DumpCommandTest.php | 4 +- .../Config/EnvironmentsCommandTest.php | 4 +- .../BuiltIn/DeployCommandMiscTasksTest.php | 24 +++++------ .../Command/BuiltIn/DeployCommandMiscTest.php | 28 ++++++------- .../BuiltIn/DeployCommandWithReleasesTest.php | 40 +++++++++---------- .../DeployCommandWithoutReleasesTest.php | 8 ++-- .../BuiltIn/Releases/ListCommandTest.php | 28 ++++++------- .../BuiltIn/Releases/RollbackCommandTest.php | 16 ++++---- tests/Command/BuiltIn/VersionCommandTest.php | 4 +- tests/MageApplicationTest.php | 20 +++++----- 12 files changed, 103 insertions(+), 99 deletions(-) diff --git a/bin/mage b/bin/mage index 26cd158..3d1b6ca 100755 --- a/bin/mage +++ b/bin/mage @@ -11,8 +11,8 @@ if (file_exists(__DIR__ . '/../../../autoload.php')) { use Mage\MageApplication; try { - $mage = new MageApplication(); - $mage->configure('.mage.yml'); + $mage = new MageApplication('.mage.yml'); + $mage->configure(); $mage->run(); } catch (Exception $exception) { printf('Error: %s' . PHP_EOL, $exception->getMessage()); diff --git a/src/MageApplication.php b/src/MageApplication.php index 6c9a92a..acbdc47 100644 --- a/src/MageApplication.php +++ b/src/MageApplication.php @@ -33,9 +33,15 @@ use Mage\Runtime\Exception\RuntimeException; class MageApplication extends Application { protected $runtime; + protected $file; - public function __construct() + /** + * @param string $file The YAML file from which to read the configuration + */ + public function __construct($file) { + $this->file = $file; + $dispatcher = new EventDispatcher(); $dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) { @@ -53,21 +59,19 @@ class MageApplication extends Application /** * Configure the Magallanes Application * - * @param string $file The YAML file from which to read the configuration - * * @throws RuntimeException */ - public function configure($file) + public function configure() { - if (!file_exists($file) || !is_readable($file)) { - throw new RuntimeException(sprintf('The file "%s" does not exists or is not readable.', $file)); + if (!file_exists($this->file) || !is_readable($this->file)) { + throw new RuntimeException(sprintf('The file "%s" does not exists or is not readable.', $this->file)); } try { $parser = new Parser(); - $config = $parser->parse(file_get_contents($file)); + $config = $parser->parse(file_get_contents($this->file)); } catch (ParseException $exception) { - throw new RuntimeException(sprintf('Error parsing the file "%s".', $file)); + throw new RuntimeException(sprintf('Error parsing the file "%s".', $this->file)); } if (array_key_exists('magephp', $config) && is_array($config['magephp'])) { @@ -89,7 +93,7 @@ class MageApplication extends Application return true; } - throw new RuntimeException(sprintf('The file "%s" does not have a valid Magallanes configuration.', $file)); + throw new RuntimeException(sprintf('The file "%s" does not have a valid Magallanes configuration.', $this->file)); } /** diff --git a/tests/Command/BuiltIn/Config/DumpCommandTest.php b/tests/Command/BuiltIn/Config/DumpCommandTest.php index f7ad66e..7723ec4 100644 --- a/tests/Command/BuiltIn/Config/DumpCommandTest.php +++ b/tests/Command/BuiltIn/Config/DumpCommandTest.php @@ -20,8 +20,8 @@ class DumpCommandTest extends TestCase { public function testConfigDumpTermination() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/basic.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/basic.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('config:dump'); diff --git a/tests/Command/BuiltIn/Config/EnvironmentsCommandTest.php b/tests/Command/BuiltIn/Config/EnvironmentsCommandTest.php index 79f78ae..f8e6995 100644 --- a/tests/Command/BuiltIn/Config/EnvironmentsCommandTest.php +++ b/tests/Command/BuiltIn/Config/EnvironmentsCommandTest.php @@ -20,8 +20,8 @@ class EnvironmentsCommandTest extends TestCase { public function testConfigDumpTermination() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/basic.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/basic.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('config:environments'); diff --git a/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php b/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php index c813e21..1aaf87e 100644 --- a/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php +++ b/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php @@ -20,8 +20,8 @@ class DeployCommandMiscTasksTest extends TestCase { public function testSymfonyEnvironmentConfiguration() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/symfony-envconf.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/symfony-envconf.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -53,8 +53,8 @@ class DeployCommandMiscTasksTest extends TestCase public function testComposerFlags() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/composer.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/composer.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -84,8 +84,8 @@ class DeployCommandMiscTasksTest extends TestCase public function testInvalidTaskName() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/invalid-task.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/invalid-task.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -100,8 +100,8 @@ class DeployCommandMiscTasksTest extends TestCase public function testBrokenGitBranch() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/broken-git-branch.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -119,8 +119,8 @@ class DeployCommandMiscTasksTest extends TestCase public function testBrokenGitCheckout() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/broken-git-branch.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -138,8 +138,8 @@ class DeployCommandMiscTasksTest extends TestCase public function testBrokenGitUpdate() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/broken-git-branch.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); diff --git a/tests/Command/BuiltIn/DeployCommandMiscTest.php b/tests/Command/BuiltIn/DeployCommandMiscTest.php index 02b3d3a..c459886 100644 --- a/tests/Command/BuiltIn/DeployCommandMiscTest.php +++ b/tests/Command/BuiltIn/DeployCommandMiscTest.php @@ -20,8 +20,8 @@ class DeployCommandMiscTest extends TestCase { public function testDeploymentWithNoHosts() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/no-hosts.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/no-hosts.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -39,8 +39,8 @@ class DeployCommandMiscTest extends TestCase public function testDeploymentWithSudo() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-sudo.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-sudo.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -78,8 +78,8 @@ class DeployCommandMiscTest extends TestCase public function testDeploymentWithBranchOverwrite() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-without-releases.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-without-releases.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -116,8 +116,8 @@ class DeployCommandMiscTest extends TestCase public function testDeploymentWithCustomTask() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-custom-task.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-custom-task.yml'); + $application->configure(); /** @var AbstractCommand $command */ @@ -150,8 +150,8 @@ class DeployCommandMiscTest extends TestCase public function testDeploymentWithErrorTaskCommands() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-with-error.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-with-error.yml'); + $application->configure(); $application->getRuntime()->setReleaseId('20170101015120'); @@ -192,8 +192,8 @@ class DeployCommandMiscTest extends TestCase public function testDeploymentWithFailingPostDeployTaskCommands() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-with-postdeploy-error.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-with-postdeploy-error.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -228,8 +228,8 @@ class DeployCommandMiscTest extends TestCase public function testDeploymentWithSkippingTask() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-skipping.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-skipping.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); diff --git a/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php b/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php index 554c56d..57747f3 100644 --- a/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php +++ b/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php @@ -20,8 +20,8 @@ class DeployCommandWithReleasesTest extends TestCase { public function testDeploymentWithReleasesCommands() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml'); + $application->configure(); $application->getRuntime()->setReleaseId('20170101015120'); @@ -71,8 +71,8 @@ class DeployCommandWithReleasesTest extends TestCase public function testDeploymentWithoutReleasesTarPrepare() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-force-tar1.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar1.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -87,8 +87,8 @@ class DeployCommandWithReleasesTest extends TestCase public function testDeploymentWithoutReleasesTarCopy() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-force-tar2.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar2.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -103,8 +103,8 @@ class DeployCommandWithReleasesTest extends TestCase public function testDeploymentWithoutReleasesTarCleanup() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-force-tar3.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar3.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -119,8 +119,8 @@ class DeployCommandWithReleasesTest extends TestCase public function testDeploymentFailCopyCommands() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-fail-copy-tar.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-fail-copy-tar.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -135,8 +135,8 @@ class DeployCommandWithReleasesTest extends TestCase public function testDeploymentWithoutReleasesForceRelease() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-force-release.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-release.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -151,8 +151,8 @@ class DeployCommandWithReleasesTest extends TestCase public function testDeploymentFailToExtract() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml'); + $application->configure(); $application->getRuntime()->setReleaseId('20170101015120'); @@ -194,8 +194,8 @@ class DeployCommandWithReleasesTest extends TestCase public function testDeploymentFailToCopy() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml'); + $application->configure(); $application->getRuntime()->setReleaseId('20170101015120'); @@ -236,8 +236,8 @@ class DeployCommandWithReleasesTest extends TestCase public function testDeploymentFailCleanup() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml'); + $application->configure(); $application->getRuntime()->setReleaseId('20170101015120'); @@ -290,8 +290,8 @@ class DeployCommandWithReleasesTest extends TestCase public function testDeploymentFailMidway() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml'); + $application->configure(); $application->getRuntime()->setReleaseId('20170101015120'); diff --git a/tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php b/tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php index 446f6ab..aa8d8f2 100644 --- a/tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php +++ b/tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php @@ -20,8 +20,8 @@ class DeployCommandWithoutReleasesTest extends TestCase { public function testDeploymentWithoutReleasesCommands() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-without-releases.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-without-releases.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); @@ -58,8 +58,8 @@ class DeployCommandWithoutReleasesTest extends TestCase public function testDeploymentFailMidway() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/testhost-without-releases.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-without-releases.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('deploy'); diff --git a/tests/Command/BuiltIn/Releases/ListCommandTest.php b/tests/Command/BuiltIn/Releases/ListCommandTest.php index f340b98..99eb5d9 100644 --- a/tests/Command/BuiltIn/Releases/ListCommandTest.php +++ b/tests/Command/BuiltIn/Releases/ListCommandTest.php @@ -20,8 +20,8 @@ class ListCommandTest extends TestCase { public function testListReleasesCommands() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/testhost.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('releases:list'); @@ -48,8 +48,8 @@ class ListCommandTest extends TestCase public function testListReleasesWithInvalidEnvironment() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/testhost.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('releases:list'); @@ -64,8 +64,8 @@ class ListCommandTest extends TestCase public function testListReleasesWithoutReleases() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/testhost-without-releases.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-without-releases.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('releases:list'); @@ -80,8 +80,8 @@ class ListCommandTest extends TestCase public function testFailToGetCurrentRelease() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/testhost-fail-get-current.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-fail-get-current.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('releases:list'); @@ -96,8 +96,8 @@ class ListCommandTest extends TestCase public function testNoReleasesAvailable() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/testhost-no-releases.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-no-releases.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('releases:list'); @@ -111,8 +111,8 @@ class ListCommandTest extends TestCase public function testFailGetReleases() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/testhost-fail-get-releases.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-fail-get-releases.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('releases:list'); @@ -127,8 +127,8 @@ class ListCommandTest extends TestCase public function testNoHosts() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/testhost-no-hosts.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-no-hosts.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('releases:list'); diff --git a/tests/Command/BuiltIn/Releases/RollbackCommandTest.php b/tests/Command/BuiltIn/Releases/RollbackCommandTest.php index 1218adc..1e34aaf 100644 --- a/tests/Command/BuiltIn/Releases/RollbackCommandTest.php +++ b/tests/Command/BuiltIn/Releases/RollbackCommandTest.php @@ -20,8 +20,8 @@ class RollbackCommandTest extends TestCase { public function testRollbackReleaseCommands() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/testhost.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('releases:rollback'); @@ -48,8 +48,8 @@ class RollbackCommandTest extends TestCase public function testRollbackReleaseWithInvalidEnvironment() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/testhost.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('releases:rollback'); @@ -64,8 +64,8 @@ class RollbackCommandTest extends TestCase public function testRollbackReleaseWithoutReleases() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/testhost-without-releases.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-without-releases.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('releases:rollback'); @@ -80,8 +80,8 @@ class RollbackCommandTest extends TestCase public function testRollbackReleaseNotAvailable() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../../Resources/testhost-not-have-release.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-not-have-release.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('releases:rollback'); diff --git a/tests/Command/BuiltIn/VersionCommandTest.php b/tests/Command/BuiltIn/VersionCommandTest.php index 2e39690..feb2af8 100644 --- a/tests/Command/BuiltIn/VersionCommandTest.php +++ b/tests/Command/BuiltIn/VersionCommandTest.php @@ -21,8 +21,8 @@ class VersionCommandTest extends TestCase { public function testVersionOutput() { - $application = new MageApplicationMockup(); - $application->configure(__DIR__ . '/../../Resources/basic.yml'); + $application = new MageApplicationMockup(__DIR__ . '/../../Resources/basic.yml'); + $application->configure(); /** @var AbstractCommand $command */ $command = $application->find('version'); diff --git a/tests/MageApplicationTest.php b/tests/MageApplicationTest.php index 265b5e9..02af709 100644 --- a/tests/MageApplicationTest.php +++ b/tests/MageApplicationTest.php @@ -20,16 +20,16 @@ class MageApplicationTest extends TestCase { public function testValidConfiguration() { - $application = new MageApplication(); - $application->configure(__DIR__ . '/Resources/basic.yml'); + $application = new MageApplication(__DIR__ . '/Resources/basic.yml'); + $application->configure(); $this->assertTrue($application instanceof MageApplication); } public function testInValidConfiguration() { try { - $application = new MageApplication(); - $application->configure(__DIR__ . '/Resources/invalid.yml'); + $application = new MageApplication(__DIR__ . '/Resources/invalid.yml'); + $application->configure(); } catch (Exception $exception) { $this->assertTrue($exception instanceof RuntimeException); $this->assertEquals(sprintf('The file "%s" does not have a valid Magallanes configuration.', __DIR__ . '/Resources/invalid.yml'), $exception->getMessage()); @@ -39,8 +39,8 @@ class MageApplicationTest extends TestCase public function testParserError() { try { - $application = new MageApplication(); - $application->configure(__DIR__ . '/Resources/invalid-yaml.yml'); + $application = new MageApplication(__DIR__ . '/Resources/invalid-yaml.yml'); + $application->configure(); } catch (Exception $exception) { $this->assertTrue($exception instanceof RuntimeException); $this->assertEquals(sprintf('Error parsing the file "%s".', __DIR__ . '/Resources/invalid-yaml.yml'), $exception->getMessage()); @@ -50,8 +50,8 @@ class MageApplicationTest extends TestCase public function testInvalidFile() { try { - $application = new MageApplication(); - $application->configure(__DIR__ . '/Resources/this-does-not-exists.yml'); + $application = new MageApplication(__DIR__ . '/Resources/this-does-not-exists.yml'); + $application->configure(); } catch (Exception $exception) { $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()); @@ -60,9 +60,9 @@ class MageApplicationTest extends TestCase public function testAppDispatcher() { - $application = new MageApplication(); + $application = new MageApplication(__DIR__ . '/Resources/basic.yml'); $application->setAutoExit(false); - $application->configure(__DIR__ . '/Resources/basic.yml'); + $application->configure(); $this->assertTrue($application instanceof MageApplication); $application->register('foo')->setCode(function () {