yapro / symfony-http-test-ext
Symfony http 测试
v1.0.1
2021-09-04 07:18 UTC
Requires
- php: >=7.1
- yapro/symfony-http-client-ext: *
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-25 11:57:17 UTC
README
解决最常见问题的特性。
如何使用
创建一个包含 getHttpClient 方法的类,例如:src/ExampleTestCase.php
包含内容
当你编写 "YourTest extends \YaPro\SymfonyHttpTestExt\BaseTestCase" 时,你会得到以下功能
- $this->getHttpClient() - 用于处理 http 客户端
- $this->getJsonHelper() - 用于处理 json
- $this->assertXXX() - 用于处理断言,例如:assertJsonResponse($json)
- 等: AssertionsTrait,ExtTrait
有用信息
- 访问内部对象 - https://symfony.com.cn/doc/current/testing.html#accessing-internal-objects
- 性能分析器 - https://symfony.com.cn/doc/current/testing.html#accessing-the-profiler-data
- HTTP 重定向 - https://symfony.com.cn/doc/current/testing.html#redirecting
- 关闭异常捕获 - https://symfony.com.cn/doc/current/testing.html#reporting-exceptions。
测试
docker build -t yapro/symfony-http-test-ext:latest -f ./Dockerfile ./ docker run --rm -v $(pwd):/app yapro/symfony-http-test-ext:latest bash -c "cd /app \ && composer install --optimize-autoloader --no-scripts --no-interaction \ && /app/vendor/bin/phpunit /app/tests"
开发者
docker build -t yapro/symfony-http-test-ext:latest -f ./Dockerfile ./
docker run -it --rm -v $(pwd):/app -w /app yapro/symfony-http-test-ext:latest bash
composer install -o