Skip to content

Commit 14c8209

Browse files
Fix test coverage
1 parent cec67d8 commit 14c8209

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/unit/Console/IOUtilTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,16 @@ public function testFormatHeadlineLong(): void
5757

5858
$this->assertEquals($long, $headline);
5959
}
60+
61+
/**
62+
* Tests IOUtil::formatHeadline
63+
*/
64+
public function testFormatHeadlineShort(): void
65+
{
66+
$text = str_repeat('x', 70) ;
67+
$expected = '==== ' . $text . ' ====';
68+
$headline = IOUtil::formatHeadline($text, 80);
69+
70+
$this->assertEquals($expected, $headline);
71+
}
6072
}

tests/unit/Runner/InstallerTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use CaptainHook\App\Git\DummyRepo;
1818
use CaptainHook\App\Hook\Mockery as HookMockery;
1919
use CaptainHook\App\Mockery as CHMockery;
20+
use Exception;
2021
use org\bovigo\vfs\vfsStream;
2122
use PHPUnit\Framework\TestCase;
2223
use RuntimeException;
@@ -300,6 +301,23 @@ public function testSkipExisting(): void
300301
$runner->run();
301302
}
302303

304+
/**
305+
* Tests Installer::writeHookFile
306+
*/
307+
public function testOnlyEnabledAndHooksToHandle(): void
308+
{
309+
$this->expectException(Exception::class);
310+
311+
$io = $this->createIOMock();
312+
$config = $this->createConfigMock();
313+
$repo = $this->createRepositoryMock();
314+
$template = $this->createTemplateMock();
315+
316+
$runner = new Installer($io, $config, $repo, $template);
317+
$runner->setHook('pre-commit');
318+
$runner->setOnlyEnabled(true);
319+
}
320+
303321
/**
304322
* Tests Installer::writeHookFile
305323
*/

0 commit comments

Comments
 (0)