Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lamoda/codeception-flysystem
Codeception FlySystem module with several adapters
https://github.com/lamoda/codeception-flysystem
codeception codeception-flysystem codeception-module flysystem php s3 sftp webdav
Last synced: about 2 months ago
JSON representation
Codeception FlySystem module with several adapters
- Host: GitHub
- URL: https://github.com/lamoda/codeception-flysystem
- Owner: lamoda
- License: mit
- Created: 2018-11-13T12:17:07.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-27T10:02:50.000Z (over 4 years ago)
- Last Synced: 2024-10-31T23:17:21.633Z (about 2 months ago)
- Topics: codeception, codeception-flysystem, codeception-module, flysystem, php, s3, sftp, webdav
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 16
- Watchers: 22
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Codeception FlySystem Extension
[![Build Status](https://travis-ci.org/lamoda/codeception-flysystem.svg?branch=master)](https://travis-ci.org/lamoda/codeception-flysystem)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/badges/build.png?b=master)](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/build-status/master)This extension supports working with [FlySystem](https://flysystem.thephpleague.com/) with several adapters.
Provides a set of methods for checking and modifying files on remote storage.
## Installation
1. Install library
```bash
composer require lamoda/codeception-flysystem
```2. Add configuration to codeception.yml
```yaml
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"
```3. Include to suite
```yaml
modules:
enabled:
- \Lamoda\Codeception\Extension\FlySystemModule
```## Supported adapters
### [sftp](https://flysystem.thephpleague.com/adapter/sftp/)
Configuration example:
```yaml
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:
```php
$fileSystem = $this->tester->getFileSystem('sftp');
```### [webdav](https://flysystem.thephpleague.com/adapter/webdav/)
Configuration example:
```yaml
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:
```php
$fileSystem = $this->tester->getFileSystem('webdav');
```### [AWS S3](https://flysystem.thephpleague.com/adapter/aws-s3/)
Configuration example:
```yaml
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:
```php
$fileSystem = $this->tester->getFileSystem('s3');
```## Usage
Get instance of FileSystem by name from config:
```php
$fileSystem = $this->tester->getFileSystem('sftp');
```Modify file on remote server:
```php
$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:
```php
$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
```bash
make php-cs-check
make php-cs-fix
```### Tests
Unit
```bash
make test-unit
```