lag / colonel-smoker-bundle
Colonel 帮助您检查应用中的烟雾
Requires
- php: ^7.2
- ext-dom: *
- doctrine/doctrine-bundle: ^1.9
- doctrine/orm: ^2.6
- fabpot/goutte: ^3.2
- symfony/config: ^4.1
- symfony/console: ^4.1
- symfony/dependency-injection: ^4.1
- symfony/filesystem: ^4.1
- symfony/http-kernel: ^4.1
- symfony/options-resolver: ^4.1
- symfony/property-access: ^4.1
- symfony/routing: ^4.1
- symfony/yaml: ^4.1
- twig/twig: ^2.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- phpstan/phpstan: ^0.11.19
- phpunit/phpunit: ^7.4
- symfony/debug: ^4.2
This package is auto-updated.
Last update: 2024-09-10 08:03:32 UTC
README
Colonel Smoker 是烟雾专家。甚至可以在将应用部署到生产环境之前,告诉您应用是否在冒烟。
Colonel Smoker 会查找您的 Symfony 应用程序的 URL(目前仅支持 Symfony),并查找 500
错误。
主要功能
- 帮助提供动态 URL 的需求参数
- 默认使用 Symfony 路由中声明的路由
- 检查响应代码
- 检查结果 HTML 是否包含您的实体中的动态数据
目标是确保您的应用程序中的每个 URL 都不包含关键错误。它特别适合具有复杂和动态数据的页面。
此包依赖于 Symfony 服务注入。如果您不熟悉此内容,可以在此处阅读文档 https://symfony.ac.cn/doc/current/service_container.html
安装
composer require --dev lag/colonel-smoker-bundle
配置
# config/packages/test/lag_smoker.yaml lag_smoker: host: 'http://127.0.0.1:8000/' # This is the default configuration # This route will be used to generated urls to test against routes: # The homepage route has no parameters and expect a 200 OK response code app.homepage: ~ # The show article requires parameters. They will be provided by the mapping "article" app.show_article: mapping: article # The mapping will be used to generated urls with dynamic parameters mapping: # This name can be anything, but it has to be unique article: # This mapping will be used with the Article entity of your application entity: App\JK\CmsBundle\Entity\Article # The property id in the route parameters (/articles/{id} for example) will be mapped with id property of your entity requirements: id: id
使用
- 首先生成 URL 缓存
bin/console smoker:generate-cache
- 然后运行烟雾测试
bin/console smoker:smoke
如果您使用 Symfony WebServer 包,不要忘记运行
bin/console server:start --env=test
。
工作原理
Colonel Smoker 将读取配置并使用 Symfony 路由构建应用程序的 URL。URL 存储在缓存中。然后它调用每个 URL 并分析响应以查找 500 错误。但它还可以测试 HTML 是否包含某些静态或动态值。
例如,如果您的应用程序处理文章,Colonel Smoker 可以检查显示文章的页面是否包含文章标题。
文档
配置参考
lag_smoker: routes: app.homepage: mapping: null provider: symfony handlers: response_code: 200 app.show_articles_redirection: mapping: article provider: my_custom_requirements_provider handlers: response_code: 302 mapping: article: entity: App\JK\CmsBundle\Entity\Article provider: symfony pattern: 'app.article_' excludes: - app.article.excluded_routes requirements: id: id categorySlug: category.slug
Colonel 依赖于 Symfony 的 DomCrawler 组件和 Goutte 客户端。
已知问题
在开发环境中,当服务器在同一台机器上(例如使用 Symfony Web 服务器时),我们多次调用 Symfony 客户端,缓存未命中以检索值并引发异常,导致一些构建失败。正在进行的补丁以避免这种情况。
## 路线图
- 添加选项以在测试中设置超时,以避免与缓存的错误
- 添加检查以查看 Web 服务器是否正在运行