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

Fix to the Media Test Failing. We need to ignore "." folder in the ge… #765

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Modules/Media/Tests/MaxFolderSizeRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function test_it_creates_instance_of_folder_size_validator()
/** @test */
public function it_validates_max_folder_size_is_valid()
{
$this->app['config']->set('asgard.media.config.max-total-size', 10000); // Mocked folder size: 480; Mocked image: ~8192
$this->app['config']->set('asgard.media.config.max-total-size', 1000); // Mocked folder size: 510

$validator = $this->buildValidator(UploadedFile::fake()->image('avatar.jpg'));
$this->assertTrue($validator->passes());
Expand All @@ -36,7 +36,7 @@ public function it_validates_max_folder_size_is_valid()
/** @test */
public function it_validates_max_folder_size_is_invalid()
{
$this->app['config']->set('asgard.media.config.max-total-size', 100);
$this->app['config']->set('asgard.media.config.max-total-size', 50); // Mocked folder size: 510

$validator = $this->buildValidator(UploadedFile::fake()->image('avatar.jpg'));
$this->assertFalse($validator->passes());
Expand Down
3 changes: 2 additions & 1 deletion Modules/Media/Validators/MaxFolderSizeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Contracts\Validation\Rule;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use FilesystemIterator;
use Symfony\Component\HttpFoundation\File\UploadedFile;

class MaxFolderSizeRule implements Rule
Expand Down Expand Up @@ -45,7 +46,7 @@ public function message()
public function getDirSize($directory) : int
{
$size = 0;
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory,FilesystemIterator::SKIP_DOTS)) as $file) {
$size += $file->getSize();
}

Expand Down