lag / colonel-smoker-bundle
The Colonel helps you to check the smoke in your application
Installs: 4 278
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 6
Type:symfony-bundle
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-11-10 08:17:10 UTC
README
The Colonel Smoker is an expert in smoke. He can even tell if your application is smoking before deploying it to production.
The Colonel Smoker find the URLs of your Symfony application (only Symfony is supported now) and looks for 500
errors.
Main features :
- helps providing requirements parameters for your dynamic URLs
- uses the routes declared in the Symfony routing by default
- check for response code
- check if the resulted html contains dynamic data from your entity
The goal is to ensure that each urls in your application does not contains critical errors. It is especially designed for application which have pages with complex and dynamic data to display.
This bundle relies on Symfony service injection. If your are not familiar with this, you can read documentation here
Installation
composer require --dev lag/colonel-smoker-bundle
Configuration
# 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
Usage
- First generate the URL cache :
bin/console smoker:generate-cache
- Then run the smoke tests :
bin/console smoker:smoke
If you use the Symfony WebServer bundle, dont forget to run
bin/console server:start --env=test
.
How it works
The Colonel Smoker will read the configuration and use the Symfony routing to build the urls of your application. Urls are stored in a cache. Then he calls each urls and analyze the response to find 500 errors. But it can tests more like if the html contains some static or dynamic values.
For example, if your application handles articles, the Colonel Smoker can check if the page displaying the article contains the article title.
Documentation
Reference Configuration
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
The Colonel relies on the Symfony DomCrawler component and the Goutte client.
Known Issues
In dev environment, we call the Symfony Client to many times when having the server on the same machine (when using the Symfony web server for example), the cache miss to retrieve value and throws an exception. It causes some build failures. A patch is in progress to avoid this.
## Road map
- Add an option to set a timeout in tests to avoid error with the cache
- Add a check to see if the web server is running