Skip to content

lamoda/codeception-flysystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Packages

No packages published

Contributors 3

  •  
  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy