mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-05-09 17:26:45 +02:00
[Nostromo] Refactor config
This commit is contained in:
parent
0b2968dfa5
commit
91da979151
4
bin/mage
4
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());
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Reference in a new issue