[Nostromo] Improve tests and coverage

This commit is contained in:
Andrés Montañez
2017-01-04 22:21:38 -03:00
parent b56e1c378c
commit f4f8bfbf05
5 changed files with 98 additions and 6 deletions
+19 -1
View File
@@ -12,6 +12,7 @@ namespace Mage\Tests;
use Mage\MageApplication;
use Mage\Runtime\Exception\RuntimeException;
use Symfony\Component\Console\Tester\ApplicationTester;
use Exception;
use PHPUnit_Framework_TestCase as TestCase;
@@ -35,7 +36,7 @@ class MageApplicationTest extends TestCase
}
}
public function testInValidFile()
public function testInvalidFile()
{
try {
$application = new MageApplication();
@@ -45,4 +46,21 @@ class MageApplicationTest extends TestCase
$this->assertEquals(sprintf('The file "%s" does not exists or is not readable.', __DIR__ . '/Resources/this-does-not-exists.yml'), $exception->getMessage());
}
}
public function testAppDispatcher()
{
$application = new MageApplication();
$application->setAutoExit(false);
$application->configure(__DIR__ . '/Resources/basic.yml');
$this->assertTrue($application instanceof MageApplication);
$application->register('foo')->setCode(function() {
throw new \RuntimeException('foo');
});
$tester = new ApplicationTester($application);
$tester->run(['command' => 'foo']);
$this->assertContains('Oops, exception thrown while running command foo', $tester->getDisplay());
}
}