Skip to content

Commit da2b36d

Browse files
committed
Allow custom wiki output targets
1 parent 9e85797 commit da2b36d

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

src/Console/Command/WikiCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
133133
$jsonOutput = $this->isJsonOutput($input);
134134
$processOutput = $jsonOutput ? new BufferedOutput() : $output;
135135
$target = (string) $input->getOption('target');
136+
$isDefaultWikiTarget = ProjectCapabilitiesResolverInterface::DEFAULT_WIKI_TARGET === $target;
136137
$cacheEnabled = $this->isCacheEnabled($input);
137138

138139
if ($input->getOption('init')) {
@@ -147,7 +148,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
147148

148149
$projectCapabilities = $this->projectCapabilitiesResolver->resolve(wikiTarget: $target);
149150

150-
if (! $projectCapabilities->hasWikiTarget()) {
151+
if ($isDefaultWikiTarget && ! $projectCapabilities->hasWikiTarget()) {
151152
return $this->success(
152153
'Skipping wiki documentation generation because the wiki target does not exist at {target}.',
153154
$input,

tests/Console/Command/WikiCommandTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,48 @@ public function executeWillSkipWhenWikiTargetDoesNotExist(): void
226226
self::assertSame(WikiCommand::SUCCESS, $this->executeCommand());
227227
}
228228

229+
/**
230+
* @return void
231+
*/
232+
#[Test]
233+
public function executeWillGenerateWhenCustomWikiTargetDoesNotExist(): void
234+
{
235+
$this->input->getOption('target')
236+
->willReturn('build/wiki');
237+
$this->projectCapabilitiesResolver->resolve(Argument::any(), Argument::any(), Argument::any())
238+
->willReturn(new ProjectCapabilities(['src/'], 'FastForward\\DevTools', false, false, false, true));
239+
$this->filesystem->getAbsolutePath('src/')
240+
->willReturn(getcwd() . '/src')
241+
->shouldBeCalled();
242+
$this->processBuilder->withArgument('--target', 'build/wiki')
243+
->willReturn($this->processBuilder->reveal())
244+
->shouldBeCalled();
245+
$this->processBuilder->withArgument('--directory', getcwd() . '/src')
246+
->willReturn($this->processBuilder->reveal())
247+
->shouldBeCalled();
248+
$this->processQueue->add($this->process->reveal(), Argument::cetera())
249+
->shouldBeCalled();
250+
$this->processQueue->run($this->output->reveal())
251+
->willReturn(WikiCommand::SUCCESS)
252+
->shouldBeCalled();
253+
$this->logger->info('Generating wiki documentation...', Argument::that(
254+
static fn(array $context): bool => $context['input'] instanceof InputInterface
255+
))->shouldBeCalled();
256+
$this->logger->log(
257+
'info',
258+
'Wiki documentation generated successfully.',
259+
Argument::that(static fn(array $context): bool => $context['input'] instanceof InputInterface
260+
&& $context['output'] instanceof OutputInterface),
261+
)->shouldBeCalled();
262+
$this->logger->log(
263+
'warning',
264+
'Skipping wiki documentation generation because the wiki target does not exist at {target}.',
265+
Argument::cetera(),
266+
)->shouldNotBeCalled();
267+
268+
self::assertSame(WikiCommand::SUCCESS, $this->executeCommand());
269+
}
270+
229271
/**
230272
* @return void
231273
*/

0 commit comments

Comments
 (0)