Skip to content

Commit 11a1d58

Browse files
committed
fix: resolved review conversations;
1 parent 76f09fc commit 11a1d58

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/Drivers/StorageDriver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function __construct()
1717
{
1818
$this->disk = Storage::disk(config('auto-doc.drivers.storage.disk'));
1919
$this->prodFilePath = config('auto-doc.drivers.storage.production_path');
20-
$this->tempFilePath = 'temp_documentation.json';
20+
$this->tempFilePath = storage_path('temp_documentation.json');
2121

2222
if (empty($this->prodFilePath)) {
2323
throw new MissedProductionFilePathException();
@@ -26,13 +26,13 @@ public function __construct()
2626

2727
public function saveTmpData($data)
2828
{
29-
$this->disk->put($this->tempFilePath, json_encode($data));
29+
file_put_contents($this->tempFilePath, json_encode($data));
3030
}
3131

3232
public function getTmpData()
3333
{
34-
if ($this->disk->exists($this->tempFilePath)) {
35-
$content = $this->disk->get($this->tempFilePath);
34+
if (file_exists($this->tempFilePath)) {
35+
$content = file_get_contents($this->tempFilePath);
3636

3737
return json_decode($content, true);
3838
}

tests/StorageDriverTest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function setUp(): void
2222
$this->disk = Storage::fake('testing');
2323

2424
$this->productionFilePath = 'documentation.json';
25-
$this->tmpDocumentationFilePath = 'temp_documentation.json';
25+
$this->tmpDocumentationFilePath = __DIR__ . '/../storage/temp_documentation.json';
2626

2727
$this->tmpData = $this->getJsonFixture('tmp_data');
2828

@@ -36,18 +36,17 @@ public function testSaveTmpData()
3636
{
3737
$this->storageDriverClass->saveTmpData($this->tmpData);
3838

39-
$this->disk->assertExists($this->tmpDocumentationFilePath);
40-
41-
$this->assertEqualsFixture('tmp_data_non_formatted.json', $this->disk->get($this->tmpDocumentationFilePath));
39+
$this->assertFileExists($this->tmpDocumentationFilePath);
40+
$this->assertFileEquals($this->generateFixturePath('tmp_data_non_formatted.json'), $this->tmpDocumentationFilePath);
4241
}
4342

4443
public function testGetTmpData()
4544
{
46-
$this->disk->put($this->tmpDocumentationFilePath, json_encode($this->tmpData));
45+
file_put_contents($this->tmpDocumentationFilePath, json_encode($this->tmpData));
4746

4847
$result = $this->storageDriverClass->getTmpData();
4948

50-
$this->assertEqualsJsonFixture('tmp_data', $result);
49+
$this->assertEquals($this->tmpData, $result);
5150
}
5251

5352
public function testGetTmpDataNoFile()
@@ -75,7 +74,7 @@ public function testGetAndSaveTmpData()
7574

7675
public function testSaveData()
7776
{
78-
$this->disk->put($this->tmpDocumentationFilePath, json_encode($this->tmpData));
77+
file_put_contents($this->tmpDocumentationFilePath, json_encode($this->tmpData));
7978

8079
$this->storageDriverClass->saveData();
8180

0 commit comments

Comments
 (0)