Skip to content

Commit c81e043

Browse files
Improve test coverage
1 parent 713b2c6 commit c81e043

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/Runner/Installer.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,16 @@ public function setHook(string $hook): Installer
142142
return $this;
143143
}
144144

145-
/** @var array<int,string>|false $hooks */
145+
/** @var array<string> $hooks */
146146
$hooks = explode(',', $hook);
147-
if ($hooks === false) {
148-
throw new Exception\InvalidHookName('Invalid hook name \'' . $hook . '\'');
149-
}
150-
151147
$hooks = array_map('trim', $hooks);
152148

153149
$hooksValidationCallback = static function (string $hook): bool {
154150
return !HookUtil::isInstallable($hook);
155151
};
156152
if (!empty(($invalidHooks = array_filter($hooks, $hooksValidationCallback)))) {
157153
throw new Exception\InvalidHookName(
158-
'Invalid hook name \'' . implode(',', $invalidHooks) . '\''
154+
'Invalid hook name \'' . implode('\', \'', $invalidHooks) . '\''
159155
);
160156
}
161157

tests/unit/Runner/InstallerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public function testHookInstallationDeclined(): void
120120
$io->expects($this->atLeast(5))->method('ask')->willReturn('n');
121121

122122
$runner = new Installer($io, $config, $repo, $template);
123+
$runner->setHook('');
123124
$runner->run();
124125

125126
$this->assertFileDoesNotExist($fakeRepo->getHookDir() . '/pre-commit');

0 commit comments

Comments
 (0)