PHP code example of bebat / filesystem-assertions

1. Go to this page and download the library: Download bebat/filesystem-assertions library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bebat / filesystem-assertions example snippets




use BeBat\FilesystemAssertions\FilesystemAssertionsTrait;
use PHPUnit\Framework\TestCase;

class SomeTest extends TestCase
{
    use FilesystemAssertionsTrait;

    // ...
}

// Assert that $directory contains one or more files.
assertDirectoryContainsFiles(string $directory, array $files, string $message = '');
assertDirectoryDoesNotContainFiles(string $directory, array $files, string $message = '')

// Assert that $file is owned by a user ID or name.
assertFileHasUserId(string $file, int $uid, string $message = '')
assertFileHasUser(string $file, string $user, string $message = '')
assertFileDoesNotHaveUserId(string $file, int $uid, string $message = '')
assertFileDoesNotHaveUser(string $file, string $user, string $message = '')

// Assert that $file has a group ID or name.
assertFileHasGroupId(string $file, int $gid, string $message = '')
assertFileHasGroup(string $file, string $group, string $message = '')
assertFileDoesNotHaveGroupId(string $file, int $gid, string $message = '')
assertFileDoesNotHaveGroup(string $file, string $group, string $message = '')

// Assert that $path is a regular file.
assertIsFile(string $path, string $message = '')
assertIsNotFile(string $path, string $message = '')

// Assert that $file is a symbolic link.
assertFileIsLink(string $file, string $message = '')
assertFileIsNotLink(string $file, string $message = '')

// Assert that $file is executable.
assertFileIsExecutable(string $file, string $message = '')
assertFileIsNotExecutable(string $file, string $message = '')

// Assert that $file is a symbolic link and points to $target.
assertSymbolicLinkPointsTo(string $file, string $target, string $message = '')
assertSymbolicLinkDoesNotPointTo(string $file, string $target, string $message = '')

// Assert that $file's permissions are exactly an octal string (or integer).
assertFilePermissionsEqual(string $file, $perms, string $message = '')
assertFilePermissionsDoNotEqual(string $file, $perms, string $message = '')

// Assert that $file's permissions MATCH an octal string (or integer).
// For example, if a file has permissions 755, 644 would match but 422 would NOT.
assertFilePermissionsMatch(string $file, $perms, string $message = '')
assertFilePermissionsDoNotMatch(string $file, $perms, string $message = '')