[Nostromo] Refactor config

This commit is contained in:
Andrés Montañez 2017-01-29 18:25:02 -03:00
parent 0b2968dfa5
commit 91da979151
12 changed files with 103 additions and 99 deletions

View file

@ -11,8 +11,8 @@ if (file_exists(__DIR__ . '/../../../autoload.php')) {
use Mage\MageApplication; use Mage\MageApplication;
try { try {
$mage = new MageApplication(); $mage = new MageApplication('.mage.yml');
$mage->configure('.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());

View file

@ -33,9 +33,15 @@ use Mage\Runtime\Exception\RuntimeException;
class MageApplication extends Application class MageApplication extends Application
{ {
protected $runtime; 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 = new EventDispatcher();
$dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) { $dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) {
@ -53,21 +59,19 @@ class MageApplication extends Application
/** /**
* Configure the Magallanes Application * Configure the Magallanes Application
* *
* @param string $file The YAML file from which to read the configuration
*
* @throws RuntimeException * @throws RuntimeException
*/ */
public function configure($file) public function configure()
{ {
if (!file_exists($file) || !is_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.', $file)); throw new RuntimeException(sprintf('The file "%s" does not exists or is not readable.', $this->file));
} }
try { try {
$parser = new Parser(); $parser = new Parser();
$config = $parser->parse(file_get_contents($file)); $config = $parser->parse(file_get_contents($this->file));
} catch (ParseException $exception) { } 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'])) { if (array_key_exists('magephp', $config) && is_array($config['magephp'])) {
@ -89,7 +93,7 @@ class MageApplication extends Application
return true; 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));
} }
/** /**

View file

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

View file

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

View file

@ -20,8 +20,8 @@ class DeployCommandMiscTasksTest extends TestCase
{ {
public function testSymfonyEnvironmentConfiguration() public function testSymfonyEnvironmentConfiguration()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/symfony-envconf.yml');
$application->configure(__DIR__ . '/../../Resources/symfony-envconf.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -53,8 +53,8 @@ class DeployCommandMiscTasksTest extends TestCase
public function testComposerFlags() public function testComposerFlags()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/composer.yml');
$application->configure(__DIR__ . '/../../Resources/composer.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -84,8 +84,8 @@ class DeployCommandMiscTasksTest extends TestCase
public function testInvalidTaskName() public function testInvalidTaskName()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/invalid-task.yml');
$application->configure(__DIR__ . '/../../Resources/invalid-task.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -100,8 +100,8 @@ class DeployCommandMiscTasksTest extends TestCase
public function testBrokenGitBranch() public function testBrokenGitBranch()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml');
$application->configure(__DIR__ . '/../../Resources/broken-git-branch.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -119,8 +119,8 @@ class DeployCommandMiscTasksTest extends TestCase
public function testBrokenGitCheckout() public function testBrokenGitCheckout()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml');
$application->configure(__DIR__ . '/../../Resources/broken-git-branch.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -138,8 +138,8 @@ class DeployCommandMiscTasksTest extends TestCase
public function testBrokenGitUpdate() public function testBrokenGitUpdate()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/broken-git-branch.yml');
$application->configure(__DIR__ . '/../../Resources/broken-git-branch.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');

View file

@ -20,8 +20,8 @@ class DeployCommandMiscTest extends TestCase
{ {
public function testDeploymentWithNoHosts() public function testDeploymentWithNoHosts()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/no-hosts.yml');
$application->configure(__DIR__ . '/../../Resources/no-hosts.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -39,8 +39,8 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithSudo() public function testDeploymentWithSudo()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-sudo.yml');
$application->configure(__DIR__ . '/../../Resources/testhost-sudo.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -78,8 +78,8 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithBranchOverwrite() public function testDeploymentWithBranchOverwrite()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-without-releases.yml');
$application->configure(__DIR__ . '/../../Resources/testhost-without-releases.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -116,8 +116,8 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithCustomTask() public function testDeploymentWithCustomTask()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-custom-task.yml');
$application->configure(__DIR__ . '/../../Resources/testhost-custom-task.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
@ -150,8 +150,8 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithErrorTaskCommands() public function testDeploymentWithErrorTaskCommands()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-with-error.yml');
$application->configure(__DIR__ . '/../../Resources/testhost-with-error.yml'); $application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');
@ -192,8 +192,8 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithFailingPostDeployTaskCommands() public function testDeploymentWithFailingPostDeployTaskCommands()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-with-postdeploy-error.yml');
$application->configure(__DIR__ . '/../../Resources/testhost-with-postdeploy-error.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -228,8 +228,8 @@ class DeployCommandMiscTest extends TestCase
public function testDeploymentWithSkippingTask() public function testDeploymentWithSkippingTask()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-skipping.yml');
$application->configure(__DIR__ . '/../../Resources/testhost-skipping.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');

View file

@ -20,8 +20,8 @@ class DeployCommandWithReleasesTest extends TestCase
{ {
public function testDeploymentWithReleasesCommands() public function testDeploymentWithReleasesCommands()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml');
$application->configure(__DIR__ . '/../../Resources/testhost.yml'); $application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');
@ -71,8 +71,8 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentWithoutReleasesTarPrepare() public function testDeploymentWithoutReleasesTarPrepare()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar1.yml');
$application->configure(__DIR__ . '/../../Resources/testhost-force-tar1.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -87,8 +87,8 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentWithoutReleasesTarCopy() public function testDeploymentWithoutReleasesTarCopy()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar2.yml');
$application->configure(__DIR__ . '/../../Resources/testhost-force-tar2.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -103,8 +103,8 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentWithoutReleasesTarCleanup() public function testDeploymentWithoutReleasesTarCleanup()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-tar3.yml');
$application->configure(__DIR__ . '/../../Resources/testhost-force-tar3.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -119,8 +119,8 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentFailCopyCommands() public function testDeploymentFailCopyCommands()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-fail-copy-tar.yml');
$application->configure(__DIR__ . '/../../Resources/testhost-fail-copy-tar.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -135,8 +135,8 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentWithoutReleasesForceRelease() public function testDeploymentWithoutReleasesForceRelease()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-force-release.yml');
$application->configure(__DIR__ . '/../../Resources/testhost-force-release.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('deploy'); $command = $application->find('deploy');
@ -151,8 +151,8 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentFailToExtract() public function testDeploymentFailToExtract()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml');
$application->configure(__DIR__ . '/../../Resources/testhost.yml'); $application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');
@ -194,8 +194,8 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentFailToCopy() public function testDeploymentFailToCopy()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml');
$application->configure(__DIR__ . '/../../Resources/testhost.yml'); $application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');
@ -236,8 +236,8 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentFailCleanup() public function testDeploymentFailCleanup()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml');
$application->configure(__DIR__ . '/../../Resources/testhost.yml'); $application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');
@ -290,8 +290,8 @@ class DeployCommandWithReleasesTest extends TestCase
public function testDeploymentFailMidway() public function testDeploymentFailMidway()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost.yml');
$application->configure(__DIR__ . '/../../Resources/testhost.yml'); $application->configure();
$application->getRuntime()->setReleaseId('20170101015120'); $application->getRuntime()->setReleaseId('20170101015120');

View file

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

View file

@ -20,8 +20,8 @@ class ListCommandTest extends TestCase
{ {
public function testListReleasesCommands() public function testListReleasesCommands()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml');
$application->configure(__DIR__ . '/../../../Resources/testhost.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');
@ -48,8 +48,8 @@ class ListCommandTest extends TestCase
public function testListReleasesWithInvalidEnvironment() public function testListReleasesWithInvalidEnvironment()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml');
$application->configure(__DIR__ . '/../../../Resources/testhost.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');
@ -64,8 +64,8 @@ class ListCommandTest extends TestCase
public function testListReleasesWithoutReleases() public function testListReleasesWithoutReleases()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-without-releases.yml');
$application->configure(__DIR__ . '/../../../Resources/testhost-without-releases.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');
@ -80,8 +80,8 @@ class ListCommandTest extends TestCase
public function testFailToGetCurrentRelease() public function testFailToGetCurrentRelease()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-fail-get-current.yml');
$application->configure(__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');
@ -96,8 +96,8 @@ class ListCommandTest extends TestCase
public function testNoReleasesAvailable() public function testNoReleasesAvailable()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-no-releases.yml');
$application->configure(__DIR__ . '/../../../Resources/testhost-no-releases.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');
@ -111,8 +111,8 @@ class ListCommandTest extends TestCase
public function testFailGetReleases() public function testFailGetReleases()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-fail-get-releases.yml');
$application->configure(__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');
@ -127,8 +127,8 @@ class ListCommandTest extends TestCase
public function testNoHosts() public function testNoHosts()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-no-hosts.yml');
$application->configure(__DIR__ . '/../../../Resources/testhost-no-hosts.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:list'); $command = $application->find('releases:list');

View file

@ -20,8 +20,8 @@ class RollbackCommandTest extends TestCase
{ {
public function testRollbackReleaseCommands() public function testRollbackReleaseCommands()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml');
$application->configure(__DIR__ . '/../../../Resources/testhost.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:rollback'); $command = $application->find('releases:rollback');
@ -48,8 +48,8 @@ class RollbackCommandTest extends TestCase
public function testRollbackReleaseWithInvalidEnvironment() public function testRollbackReleaseWithInvalidEnvironment()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost.yml');
$application->configure(__DIR__ . '/../../../Resources/testhost.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:rollback'); $command = $application->find('releases:rollback');
@ -64,8 +64,8 @@ class RollbackCommandTest extends TestCase
public function testRollbackReleaseWithoutReleases() public function testRollbackReleaseWithoutReleases()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-without-releases.yml');
$application->configure(__DIR__ . '/../../../Resources/testhost-without-releases.yml'); $application->configure();
/** @var AbstractCommand $command */ /** @var AbstractCommand $command */
$command = $application->find('releases:rollback'); $command = $application->find('releases:rollback');
@ -80,8 +80,8 @@ class RollbackCommandTest extends TestCase
public function testRollbackReleaseNotAvailable() public function testRollbackReleaseNotAvailable()
{ {
$application = new MageApplicationMockup(); $application = new MageApplicationMockup(__DIR__ . '/../../../Resources/testhost-not-have-release.yml');
$application->configure(__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');

View file

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

View file

@ -20,16 +20,16 @@ class MageApplicationTest extends TestCase
{ {
public function testValidConfiguration() public function testValidConfiguration()
{ {
$application = new MageApplication(); $application = new MageApplication(__DIR__ . '/Resources/basic.yml');
$application->configure(__DIR__ . '/Resources/basic.yml'); $application->configure();
$this->assertTrue($application instanceof MageApplication); $this->assertTrue($application instanceof MageApplication);
} }
public function testInValidConfiguration() public function testInValidConfiguration()
{ {
try { try {
$application = new MageApplication(); $application = new MageApplication(__DIR__ . '/Resources/invalid.yml');
$application->configure(__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());
@ -39,8 +39,8 @@ class MageApplicationTest extends TestCase
public function testParserError() public function testParserError()
{ {
try { try {
$application = new MageApplication(); $application = new MageApplication(__DIR__ . '/Resources/invalid-yaml.yml');
$application->configure(__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());
@ -50,8 +50,8 @@ class MageApplicationTest extends TestCase
public function testInvalidFile() public function testInvalidFile()
{ {
try { try {
$application = new MageApplication(); $application = new MageApplication(__DIR__ . '/Resources/this-does-not-exists.yml');
$application->configure(__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());
@ -60,9 +60,9 @@ class MageApplicationTest extends TestCase
public function testAppDispatcher() public function testAppDispatcher()
{ {
$application = new MageApplication(); $application = new MageApplication(__DIR__ . '/Resources/basic.yml');
$application->setAutoExit(false); $application->setAutoExit(false);
$application->configure(__DIR__ . '/Resources/basic.yml'); $application->configure();
$this->assertTrue($application instanceof MageApplication); $this->assertTrue($application instanceof MageApplication);
$application->register('foo')->setCode(function () { $application->register('foo')->setCode(function () {