codeception/module-filesystem
Codeception Filesystem module provides helpers for working with files and directories in tests. Create, copy, move, delete, and assert files/folders, handle fixtures and temp paths, and verify filesystem state as part of Codeception scenarios.
Begin by installing via Composer: composer require --dev codeception/module-filesystem. Then enable it in your acceptance.suite.yml, functional.suite.yml, or unit.suite.yml under modules:. The module provides assertions and helpers to verify filesystem state—e.g., checking if a file exists, directory has specific contents, or file contents match expected patterns. Your first use case is likely asserting file output after a command or fixture generation: I->seeFileFound('storage/app/logs/app.log') or I->seeFileContentsEqual('Expected content', 'config/test.yaml').
Use this module for deterministic filesystem assertions in tests—especially in functional/acceptance suites. Common patterns include:
$I->cleanDir('storage/app') in tearDown() or _before() to ensure isolated test runs.make:report), assert contents with $I->seeFileContains('report.txt', 'Q3 Results').$I->seeFileStructureEquals(['config/', 'config/app.php', 'storage/']) to validate scaffolded structures.$I->seeFileIsSymlink('link.txt')) or permissions ($I->seeFileHasPermissions('public/file.txt', '0644')).Symfony, Laravel) by placing it after them in suite config to ensure filesystem state is observable post-request.support directory, not the project root.$I->seeFileFound() (existence only) and $I->seeFileContentsEqual() (exact content match). For partial matches, use $I->seeFileContains().seeFileIsSymlink() returns false for broken symlinks; pair with seeFileFound() to confirm target.seeFileContentsMatch('/pattern/i') instead of full content comparison for resilience.Codeception\Module\Filesystem::getDirectory() in a custom module to inject dynamic base paths for multi-environment setups.cleanDir() deletes contents but keeps the directory—use deleteDir() to remove entirely.How can I help you explore Laravel packages today?