Skip to content

About

Codeception FlySystem module with several adapters

Topics

Resources

Stars

16 stars

Watchers

23 watching

Forks

Repository files navigation

Codeception FlySystem Extension

Build Status Scrutinizer Code Quality Code Coverage Build Status

This extension supports working with FlySystem with several adapters.

Provides a set of methods for checking and modifying files on remote storage.

Installation

  1. Install library

    composer require lamoda/codeception-flysystem
  2. 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"                         
  3. Include to suite

    modules:
        enabled:
            - \Lamoda\Codeception\Extension\FlySystemModule

Supported adapters

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');

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');

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

About

Codeception FlySystem module with several adapters

Topics

Resources

Stars

16 stars

Watchers

23 watching

Forks

Releases

Packages

Used by

Contributors

Languages