Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add getters to filesystem repository #44

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Repositories/FilesystemRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ public function all(): Collection
return $this->get($path);
});
}

public function getFilesystem(): Filesystem
{
return $this->filesystem;
}

public function getExtension(): string
{
return $this->extension;
}
}
31 changes: 31 additions & 0 deletions tests/Repositories/FilesystemRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Spatie\Sheets\Tests\Repositories;

use Illuminate\Contracts\Filesystem\Filesystem;
use PHPUnit\Framework\TestCase;
use Spatie\Sheets\Repositories\FilesystemRepository;
use Spatie\Sheets\Sheet;
Expand Down Expand Up @@ -64,4 +65,34 @@ public function it_can_get_null_on_non_existed_path()

$this->assertNull($filesystemRepository->get('invalid_path'));
}

/** @test */
public function it_can_return_instance_of_filesystem()
{
$filesystemRepository = new FilesystemRepository(
$this->createFactory(),
$this->createFilesystem()
);

$this->assertInstanceOf(Filesystem::class, $filesystemRepository->getFilesystem());
}

/** @test */
public function it_can_return_file_extension()
{
$filesystemRepository = new FilesystemRepository(
$this->createFactory(),
$this->createFilesystem()
);

$this->assertEquals('md', $filesystemRepository->getExtension());

$filesystemRepository = new FilesystemRepository(
$this->createFactory(),
$this->createFilesystem(),
'json'
);

$this->assertEquals('json', $filesystemRepository->getExtension());
}
}