forked from BookStackApp/BookStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageStorageTest.php
More file actions
30 lines (23 loc) · 928 Bytes
/
Copy pathImageStorageTest.php
File metadata and controls
30 lines (23 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
namespace Tests\Uploads;
use BookStack\Uploads\ImageStorage;
use Tests\TestCase;
class ImageStorageTest extends TestCase
{
public function test_local_image_storage_sets_755_directory_permissions()
{
if (PHP_OS_FAMILY !== 'Linux') {
$this->markTestSkipped('Test only works on Linux');
}
config()->set('filesystems.default', 'local');
$storage = $this->app->make(ImageStorage::class);
$dirToCheck = 'test-dir-perms-' . substr(md5(random_bytes(16)), 0, 6);
$disk = $storage->getDisk('gallery');
$disk->put("{$dirToCheck}/image.png", 'abc', true);
$expectedPath = public_path("uploads/images/{$dirToCheck}");
$permissionsApplied = substr(sprintf('%o', fileperms($expectedPath)), -4);
$this->assertEquals('0755', $permissionsApplied);
@unlink("{$expectedPath}/image.png");
@rmdir($expectedPath);
}
}