PHP / Laravel - 目录权限的单元测试

I have a Laravel application which has various folders that contain user uploads. Additionally, there are also seeded upload data that serves as dummy data.

When the app is pulled to the Staging server, the permissions sometimes fails on the uploads directories. So I wanted to write some tests to check that the directories/files are in fact writable

I've tired things like this:

$this->assertEquals(substr(sprintf('%o', fileperms(sprintf("%s/%s", public_path(), $document->base_dir))), -4), '0775');

However, even if the test passes, the uploads still fails due to permissions when trying it in the browser.

I also tried:

$this->assertTrue(is_writable(sprintf("%s/%s", public_path(), $document->base_dir)));

But this seemed just as inaccurate. the test would pass, but the uploads were still failing.

My question: I assume this has to do with the Users that are invoked when running the tests vs execution in the browser. So is there a more accurate way to go about testing this via PHP?