Skip to content

Commit

Permalink
fix: resolved review conversations;
Browse files Browse the repository at this point in the history
  • Loading branch information
vitgrams committed Mar 9, 2023
1 parent 76f09fc commit 11a1d58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/Drivers/StorageDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct()
{
$this->disk = Storage::disk(config('auto-doc.drivers.storage.disk'));
$this->prodFilePath = config('auto-doc.drivers.storage.production_path');
$this->tempFilePath = 'temp_documentation.json';
$this->tempFilePath = storage_path('temp_documentation.json');

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

public function saveTmpData($data)
{
$this->disk->put($this->tempFilePath, json_encode($data));
file_put_contents($this->tempFilePath, json_encode($data));
}

public function getTmpData()
{
if ($this->disk->exists($this->tempFilePath)) {
$content = $this->disk->get($this->tempFilePath);
if (file_exists($this->tempFilePath)) {
$content = file_get_contents($this->tempFilePath);

return json_decode($content, true);
}
Expand Down
13 changes: 6 additions & 7 deletions tests/StorageDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function setUp(): void
$this->disk = Storage::fake('testing');

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

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

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

$this->disk->assertExists($this->tmpDocumentationFilePath);

$this->assertEqualsFixture('tmp_data_non_formatted.json', $this->disk->get($this->tmpDocumentationFilePath));
$this->assertFileExists($this->tmpDocumentationFilePath);
$this->assertFileEquals($this->generateFixturePath('tmp_data_non_formatted.json'), $this->tmpDocumentationFilePath);
}

public function testGetTmpData()
{
$this->disk->put($this->tmpDocumentationFilePath, json_encode($this->tmpData));
file_put_contents($this->tmpDocumentationFilePath, json_encode($this->tmpData));

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

$this->assertEqualsJsonFixture('tmp_data', $result);
$this->assertEquals($this->tmpData, $result);
}

public function testGetTmpDataNoFile()
Expand Down Expand Up @@ -75,7 +74,7 @@ public function testGetAndSaveTmpData()

public function testSaveData()
{
$this->disk->put($this->tmpDocumentationFilePath, json_encode($this->tmpData));
file_put_contents($this->tmpDocumentationFilePath, json_encode($this->tmpData));

$this->storageDriverClass->saveData();

Expand Down

0 comments on commit 11a1d58

Please sign in to comment.