99class LocalDriverTest extends TestCase
1010{
1111 protected static LocalDriver $ localDriverClass ;
12- protected static string $ documentationDirectory ;
13- protected static string $ productionFilePath ;
12+ protected static string $ baseFileName ;
13+ protected static string $ baseFile ;
1414 protected static string $ tmpDocumentationFilePath ;
1515 protected static array $ tmpData ;
1616
1717 public function setUp (): void
1818 {
1919 parent ::setUp ();
2020
21- self ::$ documentationDirectory ??= config ('auto-doc.documentation_directory ' ).DIRECTORY_SEPARATOR ;
22- self ::$ productionFilePath ??= 'documentation.json ' ;
23- self ::$ tmpDocumentationFilePath ??= 'temp_documentation.json ' ;
21+ $ documentationDirectory ??= config ('auto-doc.drivers.local.directory ' );
22+ if (!str_ends_with ($ documentationDirectory , DIRECTORY_SEPARATOR )) {
23+ $ documentationDirectory .= DIRECTORY_SEPARATOR ;
24+ }
25+
26+ self ::$ baseFileName ??= 'documentation ' ;
27+ self ::$ baseFile ??= storage_path ($ documentationDirectory .self ::$ baseFileName .'.json ' );
28+ self ::$ tmpDocumentationFilePath ??= storage_path ('temp_documentation.json ' );
2429
2530 self ::$ tmpData ??= $ this ->getJsonFixture ('tmp_data ' );
2631
27- config (['auto-doc.drivers.local.production_path ' => self ::$ productionFilePath ]);
32+ config (['auto-doc.drivers.local.base_file_name ' => self ::$ baseFileName ]);
2833
2934 self ::$ localDriverClass ??= new LocalDriver ();
3035 }
@@ -33,13 +38,13 @@ public function testSaveTmpData()
3338 {
3439 self ::$ localDriverClass ->saveTmpData (self ::$ tmpData );
3540
36- $ this ->assertFileExists (self ::$ documentationDirectory . self :: $ tmpDocumentationFilePath );
37- $ this ->assertFileEquals ($ this ->generateFixturePath ('tmp_data_non_formatted.json ' ), self ::$ documentationDirectory . self :: $ tmpDocumentationFilePath );
41+ $ this ->assertFileExists (self ::$ tmpDocumentationFilePath );
42+ $ this ->assertFileEquals ($ this ->generateFixturePath ('tmp_data_non_formatted.json ' ), self ::$ tmpDocumentationFilePath );
3843 }
3944
4045 public function testGetTmpData ()
4146 {
42- file_put_contents (self ::$ documentationDirectory . self :: $ tmpDocumentationFilePath , json_encode (self ::$ tmpData ));
47+ file_put_contents (self ::$ tmpDocumentationFilePath , json_encode (self ::$ tmpData ));
4348
4449 $ result = self ::$ localDriverClass ->getTmpData ();
4550
@@ -57,7 +62,7 @@ public function testCreateClassConfigEmpty()
5762 {
5863 $ this ->expectException (MissedProductionFilePathException::class);
5964
60- config (['auto-doc.drivers.local.production_path ' => null ]);
65+ config (['auto-doc.drivers.local.base_file_name ' => null ]);
6166
6267 new LocalDriver ();
6368 }
@@ -71,19 +76,19 @@ public function testGetAndSaveTmpData()
7176
7277 public function testSaveData ()
7378 {
74- file_put_contents (self ::$ documentationDirectory . self :: $ tmpDocumentationFilePath , json_encode (self ::$ tmpData ));
79+ file_put_contents (self ::$ tmpDocumentationFilePath , json_encode (self ::$ tmpData ));
7580
7681 self ::$ localDriverClass ->saveData ();
7782
78- $ this ->assertFileExists (self ::$ documentationDirectory . self :: $ productionFilePath );
79- $ this ->assertFileEquals ($ this ->generateFixturePath ('tmp_data_non_formatted.json ' ), self ::$ documentationDirectory . self :: $ productionFilePath );
83+ $ this ->assertFileExists (self ::$ baseFile );
84+ $ this ->assertFileEquals ($ this ->generateFixturePath ('tmp_data_non_formatted.json ' ), self ::$ baseFile );
8085
81- $ this ->assertFileDoesNotExist (self ::$ documentationDirectory . self :: $ tmpDocumentationFilePath );
86+ $ this ->assertFileDoesNotExist (self ::$ tmpDocumentationFilePath );
8287 }
8388
8489 public function testGetDocumentation ()
8590 {
86- file_put_contents (self ::$ documentationDirectory . self :: $ productionFilePath , json_encode (self ::$ tmpData ));
91+ file_put_contents (self ::$ baseFile , json_encode (self ::$ tmpData ));
8792
8893 $ documentation = self ::$ localDriverClass ->getDocumentation ();
8994
@@ -94,7 +99,7 @@ public function testGetDocumentationFileNotExists()
9499 {
95100 $ this ->expectException (FileNotFoundException::class);
96101
97- config (['auto-doc.drivers.local.production_path ' => 'not_exists_file.json ' ]);
102+ config (['auto-doc.drivers.local.base_file_name ' => 'not_exists_file.json ' ]);
98103
99104 (new LocalDriver ())->getDocumentation ();
100105 }
0 commit comments