12
12
13
13
class BuildDocsCommandTest extends TestCase
14
14
{
15
- public function testBuildDocs1 ()
15
+ public function testBuildDocs ()
16
16
{
17
17
$ buildContext = $ this ->createBuildContext ();
18
18
$ outputDir = sprintf ('%s/tests/_output ' , $ buildContext ->getBasePath ());
@@ -25,22 +25,36 @@ public function testBuildDocs1()
25
25
]
26
26
);
27
27
28
- $ this ->assertContains ('[OK] Parse process complete ' , $ output );
28
+ $ this ->assertContains ('[OK] Parse process complete (0 files were loaded from cache) ' , $ output );
29
29
30
30
$ filesystem = new Filesystem ();
31
31
$ 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 );
32
41
}
33
42
34
43
public function testBuildDocsForPdf ()
35
44
{
36
45
$ buildContext = $ this ->createBuildContext ();
37
46
$ outputDir = sprintf ('%s/tests/_output ' , $ buildContext ->getBasePath ());
38
47
48
+ $ fs = new Filesystem ();
49
+ if ($ fs ->exists ($ outputDir )) {
50
+ $ fs ->remove ($ outputDir );
51
+ }
52
+
39
53
$ output = $ this ->executeCommand (
40
54
$ buildContext ,
41
55
[
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 ,
44
58
'--parse-sub-path ' => 'book ' ,
45
59
]
46
60
);
@@ -60,15 +74,12 @@ public function testBuildDocsForPdf()
60
74
$ indenter ->indent (file_get_contents (sprintf ('%s/../fixtures/expected/build-pdf/book.html ' , __DIR__ ))),
61
75
$ indenter ->indent (file_get_contents (sprintf ('%s/book.html ' , $ outputDir )))
62
76
);
77
+
78
+ $ this ->assertContains ('[OK] Parse process complete ' , $ output );
63
79
}
64
80
65
81
private function executeCommand (BuildContext $ buildContext , array $ input ): string
66
82
{
67
- $ fs = new Filesystem ();
68
- if ($ fs ->exists ($ input ['output-dir ' ])) {
69
- $ fs ->remove ($ input ['output-dir ' ]);
70
- }
71
-
72
83
$ command = new BuildDocsCommand ($ buildContext );
73
84
$ commandTester = new CommandTester ($ command );
74
85
$ commandTester ->execute ($ input );
0 commit comments