Skip to content

Commit a447332

Browse files
Fixed accidentally tab instead of spaces usage
1 parent fe65ae7 commit a447332

File tree

2 files changed

+109
-109
lines changed

2 files changed

+109
-109
lines changed

src/Runner/Installer.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,21 @@ public function setMoveExistingTo(string $backup): Installer
139139
public function setHook(string $hook): Installer
140140
{
141141
if (!empty($hook)) {
142-
$hooks = explode(',', $hook);
143-
if ($hooks === false) {
144-
throw new Exception\InvalidHookName('Invalid hook name \'' . $hook . '\'');
145-
}
146-
$hooks = array_map('trim', $hooks);
147-
$hooksValidationCallback = static function (string $hook): bool {
148-
return !HookUtil::isInstallable($hook);
149-
};
150-
if (!empty(($invalidHooks = array_filter($hooks, $hooksValidationCallback)))) {
151-
throw new Exception\InvalidHookName(
152-
'Invalid hook name \'' . implode(',', $invalidHooks) . '\''
153-
);
154-
}
155-
156-
$this->hooksToHandle = $hooks;
142+
$hooks = explode(',', $hook);
143+
if ($hooks === false) {
144+
throw new Exception\InvalidHookName('Invalid hook name \'' . $hook . '\'');
145+
}
146+
$hooks = array_map('trim', $hooks);
147+
$hooksValidationCallback = static function (string $hook): bool {
148+
return !HookUtil::isInstallable($hook);
149+
};
150+
if (!empty(($invalidHooks = array_filter($hooks, $hooksValidationCallback)))) {
151+
throw new Exception\InvalidHookName(
152+
'Invalid hook name \'' . implode(',', $invalidHooks) . '\''
153+
);
154+
}
155+
156+
$this->hooksToHandle = $hooks;
157157
}
158158

159159
return $this;

tests/unit/Console/Command/InstallTest.php

Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -115,98 +115,98 @@ public function testInstallPreCommitHook(): void
115115
$this->assertTrue($repo->hookExists('pre-commit'));
116116
}
117117

118-
/**
119-
* Tests Install::run
120-
*
121-
* @throws \Exception
122-
*/
123-
public function testInstallMultipleHooks(): void
124-
{
125-
$repo = new DummyRepo();
126-
$output = new NullOutput();
127-
$input = new ArrayInput(
128-
[
129-
'hook' => 'pre-commit,pre-push,post-checkout',
130-
'--configuration' => CH_PATH_FILES . '/template/captainhook.json',
131-
'--git-directory' => $repo->getGitDir()
132-
]
133-
);
134-
135-
$install = new Install(new Resolver(CH_PATH_FILES . '/bin/captainhook'));
136-
$install->run($input, $output);
137-
138-
$this->assertTrue($repo->hookExists('pre-commit'));
139-
$this->assertTrue($repo->hookExists('pre-push'));
140-
$this->assertTrue($repo->hookExists('post-checkout'));
141-
}
142-
143-
/**
144-
* Tests Install::run
145-
*
146-
* @throws \Exception
147-
*/
148-
public function testInstallMultipleHooksWithSpacesAfterAndBetweenSeparator(): void
149-
{
150-
$repo = new DummyRepo();
151-
$output = new NullOutput();
152-
$input = new ArrayInput(
153-
[
154-
'hook' => ' pre-commit , pre-push , post-checkout, post-commit',
155-
'--configuration' => CH_PATH_FILES . '/template/captainhook.json',
156-
'--git-directory' => $repo->getGitDir()
157-
]
158-
);
159-
160-
$install = new Install(new Resolver(CH_PATH_FILES . '/bin/captainhook'));
161-
$install->run($input, $output);
162-
163-
$this->assertTrue($repo->hookExists('pre-commit'));
164-
$this->assertTrue($repo->hookExists('pre-push'));
165-
$this->assertTrue($repo->hookExists('post-checkout'));
166-
}
167-
168-
/**
169-
* Tests Install::run
170-
*
171-
* @throws \Exception
172-
*/
173-
public function testInstallMultipleHooksWithOneWrong(): void
174-
{
175-
$this->expectException(\CaptainHook\App\Exception\InvalidHookName::class);
176-
$repo = new DummyRepo();
177-
$output = new NullOutput();
178-
$input = new ArrayInput(
179-
[
180-
'hook' => 'pre-commit,pre-push,post-checkout,something-wrong',
181-
'--configuration' => CH_PATH_FILES . '/template/captainhook.json',
182-
'--git-directory' => $repo->getGitDir()
183-
]
184-
);
185-
186-
$install = new Install(new Resolver(CH_PATH_FILES . '/bin/captainhook'));
187-
$install->run($input, $output);
188-
}
189-
190-
191-
/**
192-
* Tests Install::run
193-
*
194-
* @throws \Exception
195-
*/
196-
public function testInstallMultipleHooksWithMultipleWrong(): void
197-
{
198-
$this->expectException(\CaptainHook\App\Exception\InvalidHookName::class);
199-
$repo = new DummyRepo();
200-
$output = new NullOutput();
201-
$input = new ArrayInput(
202-
[
203-
'hook' => 'pre-commit,pre-push,post-checkout,something-wrong1,something-wrong2',
204-
'--configuration' => CH_PATH_FILES . '/template/captainhook.json',
205-
'--git-directory' => $repo->getGitDir()
206-
]
207-
);
208-
209-
$install = new Install(new Resolver(CH_PATH_FILES . '/bin/captainhook'));
210-
$install->run($input, $output);
211-
}
118+
/**
119+
* Tests Install::run
120+
*
121+
* @throws \Exception
122+
*/
123+
public function testInstallMultipleHooks(): void
124+
{
125+
$repo = new DummyRepo();
126+
$output = new NullOutput();
127+
$input = new ArrayInput(
128+
[
129+
'hook' => 'pre-commit,pre-push,post-checkout',
130+
'--configuration' => CH_PATH_FILES . '/template/captainhook.json',
131+
'--git-directory' => $repo->getGitDir(),
132+
]
133+
);
134+
135+
$install = new Install(new Resolver(CH_PATH_FILES . '/bin/captainhook'));
136+
$install->run($input, $output);
137+
138+
$this->assertTrue($repo->hookExists('pre-commit'));
139+
$this->assertTrue($repo->hookExists('pre-push'));
140+
$this->assertTrue($repo->hookExists('post-checkout'));
141+
}
142+
143+
/**
144+
* Tests Install::run
145+
*
146+
* @throws \Exception
147+
*/
148+
public function testInstallMultipleHooksWithSpacesAfterAndBetweenSeparator(): void
149+
{
150+
$repo = new DummyRepo();
151+
$output = new NullOutput();
152+
$input = new ArrayInput(
153+
[
154+
'hook' => ' pre-commit , pre-push , post-checkout, post-commit',
155+
'--configuration' => CH_PATH_FILES . '/template/captainhook.json',
156+
'--git-directory' => $repo->getGitDir(),
157+
]
158+
);
159+
160+
$install = new Install(new Resolver(CH_PATH_FILES . '/bin/captainhook'));
161+
$install->run($input, $output);
162+
163+
$this->assertTrue($repo->hookExists('pre-commit'));
164+
$this->assertTrue($repo->hookExists('pre-push'));
165+
$this->assertTrue($repo->hookExists('post-checkout'));
166+
}
167+
168+
/**
169+
* Tests Install::run
170+
*
171+
* @throws \Exception
172+
*/
173+
public function testInstallMultipleHooksWithOneWrong(): void
174+
{
175+
$this->expectException(\CaptainHook\App\Exception\InvalidHookName::class);
176+
$repo = new DummyRepo();
177+
$output = new NullOutput();
178+
$input = new ArrayInput(
179+
[
180+
'hook' => 'pre-commit,pre-push,post-checkout,something-wrong',
181+
'--configuration' => CH_PATH_FILES . '/template/captainhook.json',
182+
'--git-directory' => $repo->getGitDir(),
183+
]
184+
);
185+
186+
$install = new Install(new Resolver(CH_PATH_FILES . '/bin/captainhook'));
187+
$install->run($input, $output);
188+
}
189+
190+
191+
/**
192+
* Tests Install::run
193+
*
194+
* @throws \Exception
195+
*/
196+
public function testInstallMultipleHooksWithMultipleWrong(): void
197+
{
198+
$this->expectException(\CaptainHook\App\Exception\InvalidHookName::class);
199+
$repo = new DummyRepo();
200+
$output = new NullOutput();
201+
$input = new ArrayInput(
202+
[
203+
'hook' => 'pre-commit,pre-push,post-checkout,something-wrong1,something-wrong2',
204+
'--configuration' => CH_PATH_FILES . '/template/captainhook.json',
205+
'--git-directory' => $repo->getGitDir(),
206+
]
207+
);
208+
209+
$install = new Install(new Resolver(CH_PATH_FILES . '/bin/captainhook'));
210+
$install->run($input, $output);
211+
}
212212
}

0 commit comments

Comments
 (0)