feat: adds toHaveFileSystemPermissions expectation

This commit is contained in:
Nuno Maduro
2024-07-14 23:16:04 +01:00
parent d3be6b72dd
commit 0331a87be1
9 changed files with 58 additions and 4 deletions

View File

@ -434,6 +434,19 @@ final class Expectation
return ToUse::make($this, $targets);
}
/**
* Asserts that the given expectation target does have the given permissions
*/
public function toHaveFileSystemPermissions(string $permissions): ArchExpectation
{
return Targeted::make(
$this,
fn (ObjectDescription $object): bool => substr(sprintf('%o', fileperms($object->path)), -4) === $permissions,
sprintf('permissions to be [%s]', $permissions),
FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),
);
}
/**
* Asserts that the given expectation target use the "declare(strict_types=1)" declaration.
*/