Skip to content

Commit

Permalink
Missing code coverage test
Browse files Browse the repository at this point in the history
  • Loading branch information
Danzabar committed Jan 6, 2016
1 parent 0b7a4ba commit 0d6293d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use Danzabar\CLI\Application;
use Phalcon\Loader;
use Phalcon\DI;
use Phalcon\CLI\Dispatcher;
use \Mockery as m;

/**
Expand Down Expand Up @@ -179,4 +181,32 @@ public function test_helperSetUp()
$this->assertInstanceOf('Danzabar\CLI\Tasks\Helpers\Confirmation', $helpers->load('confirm'));
$this->assertInstanceOf('Danzabar\CLI\Tasks\Helpers\Table', $helpers->load('table'));
}

/**
* Test that the format args method in the application returns an empty array when an exception is thrown
*
* @return void
* @author Dan Cox
*/
public function test_formatArgsReturnsEmptyOnException()
{
$library = m::mock('TaskLibrary');
$dispatch = m::mock('Dispatch');

$library->shouldReceive('add');
$library->shouldReceive('getAll')->andReturn([]);
$library->shouldReceive('find')->andThrow('Exception');

$dispatch->shouldReceive('setDefaultTask');
$dispatch->shouldReceive('setDefaultAction');
$dispatch->shouldReceive('setTaskSuffix');
$dispatch->shouldReceive('setActionSuffix');
$dispatch->shouldReceive('setDI');

$dispatch->shouldReceive('dispatch')->once();

$app = new Application(new DI, $dispatch, $library);

$app->start(['test', 'test']);
}
} // END class ApplicationTest extends \PHPUnit_Framework_TestCase

0 comments on commit 0d6293d

Please sign in to comment.