mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	[Nostromo] Improve tests. Mess Detector recommendations.
This commit is contained in:
		
							parent
							
								
									193265e424
								
							
						
					
					
						commit
						93af5ee8cc
					
				@ -20,7 +20,8 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
 | 
				
			|||||||
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
 | 
					use Symfony\Component\Console\Event\ConsoleExceptionEvent;
 | 
				
			||||||
use Symfony\Component\Console\ConsoleEvents;
 | 
					use Symfony\Component\Console\ConsoleEvents;
 | 
				
			||||||
use Symfony\Component\Console\Application;
 | 
					use Symfony\Component\Console\Application;
 | 
				
			||||||
use Symfony\Component\Yaml\Yaml;
 | 
					use Symfony\Component\Yaml\Parser;
 | 
				
			||||||
 | 
					use Symfony\Component\Yaml\Exception\ParseException;
 | 
				
			||||||
use ReflectionClass;
 | 
					use ReflectionClass;
 | 
				
			||||||
use Mage\Runtime\Exception\RuntimeException;
 | 
					use Mage\Runtime\Exception\RuntimeException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -62,7 +63,13 @@ class MageApplication extends Application
 | 
				
			|||||||
            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.', $file));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $config = Yaml::parse(file_get_contents($file));
 | 
					        try {
 | 
				
			||||||
 | 
					            $parser = new Parser();
 | 
				
			||||||
 | 
					            $config = $parser->parse(file_get_contents($file));
 | 
				
			||||||
 | 
					        } catch (ParseException $exception) {
 | 
				
			||||||
 | 
					            throw new RuntimeException(sprintf('Error parsing the file "%s".', $file));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (array_key_exists('magephp', $config)) {
 | 
					        if (array_key_exists('magephp', $config)) {
 | 
				
			||||||
            $config = $config['magephp'];
 | 
					            $config = $config['magephp'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -80,9 +87,10 @@ class MageApplication extends Application
 | 
				
			|||||||
            $this->runtime->setLogger($logger);
 | 
					            $this->runtime->setLogger($logger);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->loadBuiltInCommands();
 | 
					            $this->loadBuiltInCommands();
 | 
				
			||||||
        } else {
 | 
					            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.', $file));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
@ -36,6 +36,17 @@ class MageApplicationTest extends TestCase
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function testParserError()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            $application = new MageApplication();
 | 
				
			||||||
 | 
					            $application->configure(__DIR__ . '/Resources/invalid-yaml.yml');
 | 
				
			||||||
 | 
					        } catch (Exception $exception) {
 | 
				
			||||||
 | 
					            $this->assertTrue($exception instanceof RuntimeException);
 | 
				
			||||||
 | 
					            $this->assertEquals(sprintf('Error parsing the file "%s".', __DIR__ . '/Resources/invalid-yaml.yml'), $exception->getMessage());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function testInvalidFile()
 | 
					    public function testInvalidFile()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										6
									
								
								src/Mage/Tests/Resources/invalid-yaml.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/Mage/Tests/Resources/invalid-yaml.yml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					magephp:
 | 
				
			||||||
 | 
					  environments:
 | 
				
			||||||
 | 
					      hosts:
 | 
				
			||||||
 | 
					        - host1
 | 
				
			||||||
 | 
					         - host2
 | 
				
			||||||
 | 
					      - host3
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user