Skip to content

Commit 847ef13

Browse files
committed
Issue #20: Pushed code coverage to 100%.
Signed-off-by: alexmerlin <alex.merlin.1985@gmail.com>
1 parent 71de84a commit 847ef13

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

test/ApplicationTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Dot\Cli\Application;
88
use Dot\Cli\FileLocker;
99
use Dot\Cli\FileLockerInterface;
10+
use Exception;
1011
use PHPUnit\Framework\TestCase;
1112
use Symfony\Component\Console\Command\Command;
1213
use Symfony\Component\Console\Input\StringInput;
@@ -20,7 +21,25 @@ class ApplicationTest extends TestCase
2021
/**
2122
* @throws Throwable
2223
*/
23-
public function testDoRun(): void
24+
public function testDoRunWillFailWithoutLockFile(): void
25+
{
26+
$fileLocker = $this->createMock(FileLockerInterface::class);
27+
28+
$exception = new Exception();
29+
$fileLocker->expects($this->once())->method('lock')->willThrowException($exception);
30+
31+
$input = new StringInput('list');
32+
$output = new BufferedOutput();
33+
34+
$application = new Application($fileLocker, $this->getConfig()['dot_cli']);
35+
$result = $application->doRun($input, $output);
36+
$this->assertSame($result, Command::FAILURE);
37+
}
38+
39+
/**
40+
* @throws Throwable
41+
*/
42+
public function testDoRunWillSucceed(): void
2443
{
2544
$config = $this->getConfig();
2645

test/Factory/ApplicationFactoryTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Psr\Container\ContainerExceptionInterface;
1515
use Psr\Container\ContainerInterface;
1616
use Psr\Container\NotFoundExceptionInterface;
17+
use Symfony\Component\EventDispatcher\EventDispatcher;
1718

1819
class ApplicationFactoryTest extends TestCase
1920
{
@@ -129,12 +130,13 @@ public function testWillCreateApplication(): void
129130

130131
$container->method('has')->willReturnMap([
131132
['config', true],
132-
['Dot\Cli\Factory\SymfonyEventDispatcher', false],
133+
['Dot\Cli\Factory\SymfonyEventDispatcher', true],
133134
[FileLockerInterface::class, true],
134135
]);
135136

136137
$container->method('get')->willReturnMap([
137138
['config', $this->getConfig()],
139+
['Dot\Cli\Factory\SymfonyEventDispatcher', new EventDispatcher()],
138140
[FileLockerInterface::class, $fileLocker],
139141
]);
140142

0 commit comments

Comments
 (0)