labbati/randomized-paths

从DataDog/dd-trace-php/tests/randomized生成随机路径的生成器

v8.1.3.0 2022-03-29 09:24 UTC

README

Composer包,使任何项目都能通过DataDog/dd-trace-php/tests/randomized/app生成器提供的随机路径可用。

这绝对不适用于生产环境。这仅适用于测试环境。

使用方法

根据版本,将以下内容添加到您的composer.json中。

{
    ...
    "require-dev": {
        "labbati/randomized-paths": "<PHP_MAJOR>.<PHP_MINOR>.*"
    }
    ...
}

您需要一些伴随服务来运行此工具。您可以从以下列表中选择。

// docker-compose.yml

....

  redis:
    image: redis:latest

  httpbin:
    image: kennethreitz/httpbin

  memcached:
    image: "memcached:1.5-alpine"

  elasticsearch:
    image: "elasticsearch:6.8.13"
    environment:
      - discovery.type=single-node

  mysql:
    image: mysql:5.7
    environment:
      - MYSQL_ROOT_PASSWORD=test
      - MYSQL_PASSWORD=test
      - MYSQL_USER=test
      - MYSQL_DATABASE=test

....

使用它们(调整主机名)


use RandomizedTests\RandomExecutionPath;
use RandomizedTests\RandomExecutionPathConfiguration;
use RandomizedTests\SnippetsConfiguration;

$snippetsConfiguration = (new SnippetsConfiguration())
    ->withHttpBinHost('httpbin')
    ->withElasticSearchHost('elasticsearch')
    ->withMysqlHost('mysql')
    ->withMysqlUser('test')
    ->withMysqlPassword('test')
    ->withMysqlDb('test')
    ->withRedisHost('redis')
    ->withMemcachedHost('memcached');
$randomizerConfiguration = new RandomExecutionPathConfiguration(
    $snippetsConfiguration,
    isset($queries['seed']) ? intval($queries['seed']) : null,
    true, // true for web, false for CLI
    isset($queries['execution_path'])
);