9
9
10
10
namespace SymfonyDocsBuilder \Tests ;
11
11
12
- use Doctrine \RST \Builder ;
13
12
use Doctrine \RST \Configuration ;
14
- use Doctrine \RST \Meta \CachedMetasLoader ;
15
- use Doctrine \RST \Meta \Metas ;
16
13
use Doctrine \RST \Parser ;
17
14
use Gajus \Dindent \Indenter ;
18
- use PHPUnit \Framework \TestCase ;
19
- use Symfony \Component \Console \Helper \ProgressBar ;
20
- use Symfony \Component \Console \Output \NullOutput ;
21
15
use Symfony \Component \DomCrawler \Crawler ;
22
- use Symfony \Component \Filesystem \Filesystem ;
23
16
use Symfony \Component \Finder \Finder ;
24
- use SymfonyDocsBuilder \BuildConfig ;
17
+ use SymfonyDocsBuilder \DocBuilder ;
25
18
use SymfonyDocsBuilder \Generator \JsonGenerator ;
26
19
use SymfonyDocsBuilder \KernelFactory ;
27
20
28
- class IntegrationTest extends TestCase
21
+ class IntegrationTest extends AbstractIntegrationTest
29
22
{
30
23
/**
31
24
* @dataProvider integrationProvider
32
25
*/
33
26
public function testIntegration (string $ folder )
34
27
{
35
- $ fs = new Filesystem ();
36
- $ fs ->remove ([__DIR__ .'/_output ' , __DIR__ .'/_cache ' ]);
37
- $ fs ->mkdir ([__DIR__ .'/_output ' , __DIR__ .'/_cache ' ]);
38
-
39
28
$ buildConfig = $ this ->createBuildConfig (sprintf ('%s/fixtures/source/%s ' , __DIR__ , $ folder ));
40
-
41
- $ builder = new Builder (
42
- KernelFactory::createKernel ($ buildConfig )
43
- );
44
-
45
- $ builder ->build (
46
- sprintf ('%s/fixtures/source/%s ' , __DIR__ , $ folder ),
47
- __DIR__ .'/_output '
48
- );
29
+ $ builder = new DocBuilder ();
30
+ $ buildResult = $ builder ->build ($ buildConfig );
49
31
50
32
$ finder = new Finder ();
51
33
$ finder ->in (sprintf ('%s/fixtures/expected/%s ' , __DIR__ , $ folder ))
@@ -55,7 +37,7 @@ public function testIntegration(string $folder)
55
37
$ indenter = $ this ->createIndenter ();
56
38
foreach ($ finder as $ expectedFile ) {
57
39
$ relativePath = $ expectedFile ->getRelativePathname ();
58
- $ actualFilename = __DIR__ . ' /_output / ' .$ relativePath ;
40
+ $ actualFilename = $ buildConfig -> getOutputDir (). ' / ' .$ relativePath ;
59
41
$ this ->assertFileExists ($ actualFilename );
60
42
61
43
$ this ->assertSame (
@@ -66,13 +48,9 @@ public function testIntegration(string $folder)
66
48
);
67
49
}
68
50
69
- $ metas = $ builder ->getMetas ();
70
- $ jsonGenerator = new JsonGenerator ($ metas , $ buildConfig );
71
- $ jsonGenerator ->generateJson ();
72
-
73
51
foreach ($ finder as $ htmlFile ) {
74
52
$ relativePath = $ htmlFile ->getRelativePathname ();
75
- $ actualFilename = __DIR__ . ' /_output / ' .str_replace ('.html ' , '.fjson ' , $ relativePath );
53
+ $ actualFilename = $ buildConfig -> getOutputDir (). ' / ' .str_replace ('.html ' , '.fjson ' , $ relativePath );
76
54
$ this ->assertFileExists ($ actualFilename );
77
55
78
56
$ jsonData = json_decode (file_get_contents ($ actualFilename ), true );
@@ -269,16 +247,6 @@ public function parserUnitBlockProvider()
269
247
];
270
248
}
271
249
272
- private function createBuildConfig (string $ sourceDir ): BuildConfig
273
- {
274
- return (new BuildConfig ())
275
- ->setSymfonyVersion ('4.0 ' )
276
- ->setContentDir ($ sourceDir )
277
- ->disableBuildCache ()
278
- ->setOutputDir (__DIR__ .'/_output ' )
279
- ;
280
- }
281
-
282
250
private function createIndenter (): Indenter
283
251
{
284
252
$ indenter = new Indenter ();
0 commit comments