Skip to content

Commit 81c563d

Browse files
committed
display how many files were loaded from cache
1 parent a1313b7 commit 81c563d

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

src/Command/BuildDocsCommand.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
8787
}
8888

8989
$this->io->newLine(2);
90-
$this->io->success('Parse process complete');
90+
91+
$successMessage = 'Parse process complete';
92+
93+
if (!$this->buildContext->getDisableCache()) {
94+
$successMessage = sprintf(
95+
'%s (%d files were loaded from cache)',
96+
$successMessage,
97+
$this->finder->count() - count($this->builder->getDocuments()->getAll())
98+
);
99+
}
100+
$this->io->success($successMessage);
91101
}
92102

93103
private function generateJson()

tests/Command/BuildDocsCommandTest.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class BuildDocsCommandTest extends TestCase
1414
{
15-
public function testBuildDocs1()
15+
public function testBuildDocs()
1616
{
1717
$buildContext = $this->createBuildContext();
1818
$outputDir = sprintf('%s/tests/_output', $buildContext->getBasePath());
@@ -25,22 +25,36 @@ public function testBuildDocs1()
2525
]
2626
);
2727

28-
$this->assertContains('[OK] Parse process complete', $output);
28+
$this->assertContains('[OK] Parse process complete (0 files were loaded from cache)', $output);
2929

3030
$filesystem = new Filesystem();
3131
$this->assertTrue($filesystem->exists(sprintf('%s/_images/symfony-logo.png', $outputDir)));
32+
33+
$output = $this->executeCommand(
34+
$buildContext,
35+
[
36+
'source-dir' => sprintf('%s/tests/fixtures/source/main', $buildContext->getBasePath()),
37+
'output-dir' => $outputDir,
38+
]
39+
);
40+
$this->assertContains('[OK] Parse process complete (3 files were loaded from cache)', $output);
3241
}
3342

3443
public function testBuildDocsForPdf()
3544
{
3645
$buildContext = $this->createBuildContext();
3746
$outputDir = sprintf('%s/tests/_output', $buildContext->getBasePath());
3847

48+
$fs = new Filesystem();
49+
if ($fs->exists($outputDir)) {
50+
$fs->remove($outputDir);
51+
}
52+
3953
$output = $this->executeCommand(
4054
$buildContext,
4155
[
42-
'source-dir' => sprintf('%s/tests/fixtures/source/build-pdf', $buildContext->getBasePath()),
43-
'output-dir' => $outputDir,
56+
'source-dir' => sprintf('%s/tests/fixtures/source/build-pdf', $buildContext->getBasePath()),
57+
'output-dir' => $outputDir,
4458
'--parse-sub-path' => 'book',
4559
]
4660
);
@@ -60,15 +74,12 @@ public function testBuildDocsForPdf()
6074
$indenter->indent(file_get_contents(sprintf('%s/../fixtures/expected/build-pdf/book.html', __DIR__))),
6175
$indenter->indent(file_get_contents(sprintf('%s/book.html', $outputDir)))
6276
);
77+
78+
$this->assertContains('[OK] Parse process complete', $output);
6379
}
6480

6581
private function executeCommand(BuildContext $buildContext, array $input): string
6682
{
67-
$fs = new Filesystem();
68-
if ($fs->exists($input['output-dir'])) {
69-
$fs->remove($input['output-dir']);
70-
}
71-
7283
$command = new BuildDocsCommand($buildContext);
7384
$commandTester = new CommandTester($command);
7485
$commandTester->execute($input);

0 commit comments

Comments
 (0)