lamoda/codeception-flysystem

用于代码ception测试的远程文件检查器

3.0.0 2020-04-27 10:00 UTC

This package is auto-updated.

Last update: 2024-08-27 19:45:11 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Build Status

此扩展支持与多个适配器一起使用 FlySystem

提供了一系列方法来检查和修改远程存储上的文件。

安装

  1. 安装库

    composer require lamoda/codeception-flysystem
  2. 将配置添加到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. 包含到测试套件

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

支持的适配器

sftp

配置示例

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: "/"

使用方法

$fileSystem = $this->tester->getFileSystem('sftp');

webdav

配置示例

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"

使用方法

$fileSystem = $this->tester->getFileSystem('webdav');

AWS S3

配置示例

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" 

使用方法

$fileSystem = $this->tester->getFileSystem('s3');

使用方法

从配置中通过名称获取FileSystem实例

$fileSystem = $this->tester->getFileSystem('sftp');

修改远程服务器上的文件

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

检查远程服务器上的文件

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

开发

PHP编码标准修复器

make php-cs-check
make php-cs-fix

测试

单元测试

make test-unit