lamoda / codeception-flysystem
Remote files checker for codeception tests
Installs: 5 111
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 22
Forks: 3
Open Issues: 0
Requires
- php: >=7.1
- codeception/codeception: ^4.0
- league/flysystem-aws-s3-v3: ~1.0
- league/flysystem-sftp: ~1.0
- league/flysystem-webdav: ~1.0
- oneup/flysystem-bundle: ~3.0
Requires (Dev)
- codeception/module-asserts: ^1.2
- friendsofphp/php-cs-fixer: ^2.13
This package is auto-updated.
Last update: 2024-10-27 20:15:36 UTC
README
This extension supports working with FlySystem with several adapters.
Provides a set of methods for checking and modifying files on remote storage.
Installation
-
Install library
composer require lamoda/codeception-flysystem
-
Add configuration to codeception.yml
modules: config: \Lamoda\Codeception\Extension\FlySystemModule: adapters: webdav: builderAdapter: \Lamoda\Codeception\Extension\AdapterFactory\WebdavAdapterFactory config: baseUri: "http://webdav-host" userName: "userName" password: "password" authType: "authType" sftp: builderAdapter: \Lamoda\Codeception\Extension\AdapterFactory\SftpAdapterFactory config: host: "http://sftp-host" username: "username" password: "password" port: "22" root: "/" s3: builderAdapter: \Lamoda\Codeception\Extension\AdapterFactory\AwsS3AdapterFactory config: bucket: "your-bucket" endpoint: "endpoint" # if you are using S3-compatible object storage service credentials: key: "key" secret: "secret" region: "region" version: "version"
-
Include to suite
modules: enabled: - \Lamoda\Codeception\Extension\FlySystemModule
Supported adapters
sftp
Configuration example:
modules: config: \Lamoda\Codeception\Extension\FlySystemModule: adapters: sftp: builderAdapter: \Lamoda\Codeception\Extension\AdapterFactory\SftpAdapterFactory config: host: "http://sftp-host" username: "username" password: "password" port: "22" root: "/"
Usage:
$fileSystem = $this->tester->getFileSystem('sftp');
webdav
Configuration example:
modules: config: \Lamoda\Codeception\Extension\FlySystemModule: adapters: webdav: builderAdapter: \Lamoda\Codeception\Extension\AdapterFactory\WebdavAdapterFactory config: baseUri: "http://webdav-host" userName: "userName" password: "password" authType: "authType"
Usage:
$fileSystem = $this->tester->getFileSystem('webdav');
AWS S3
Configuration example:
modules: config: \Lamoda\Codeception\Extension\FlySystemModule: adapters: s3: builderAdapter: \Lamoda\Codeception\Extension\AdapterFactory\AwsS3AdapterFactory config: bucket: "your-bucket" endpoint: "endpoint" # if you are using S3-compatible object storage service credentials: key: "key" secret: "secret" region: "region" version: "version"
Usage:
$fileSystem = $this->tester->getFileSystem('s3');
Usage
Get instance of FileSystem by name from config:
$fileSystem = $this->tester->getFileSystem('sftp');
Modify file on remote server:
$fileSystem->clearDir('/path/to/dir'); $fileSystem->writeFile('test.txt', 'Hello world!'); $fileSystem->copyFile('test.txt', 'test_copy.txt'); $fileSystem->deleteFile('test.txt'); $files = $fileSystem->grabFileList('/path/to/dir');
Check files on remote server:
$fileSystem->canSeeFile('test_copy.txt'); $fileSystem->cantSeeFile('test.txt'); $fileSystem->seeInFile('test_copy.txt', 'Hello'); $fileSystem->seeFilesCount('/path/to/dir', 1); $fileSystem->seeFileFoundMatches('/copy$/', '/path/to/dir'); $fileSystem->dontSeeFileFoundMatches('/test$/', '/path/to/dir');
Development
PHP Coding Standards Fixer
make php-cs-check make php-cs-fix
Tests
Unit
make test-unit