elbformat / symfony-behat-bundle
Predefined, extensible behat contexts for symfony applications.
Installs: 6 891
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 11
Type:symfony-bundle
Requires
- php: >=8.1
- ext-dom: *
- ext-json: *
- behat/behat: ^3.8
- friends-of-behat/symfony-extension: ^2.2
- symfony/dom-crawler: ^5.4|^6.2
- symfony/property-access: ^5.4|^6.2
Requires (Dev)
- doctrine/orm: ^2.12
- friendsofphp/php-cs-fixer: ^3.3
- phpunit/phpunit: ^9.5
- slope-it/clock-mock: ^0.4.0
- symfony/framework-bundle: ^5.4|^6.2
- symfony/http-client: ^5.4|^6.2
- symfony/mailer: ^5.4|^6.2
- vimeo/psalm: ^4.13
- dev-main
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.0
- dev-renovate/php-8.x
- dev-renovate/major-symfony
- dev-renovate/codecov-5.x
- dev-array_support
- dev-renovate/doctrine-orm-3.x
- dev-command-input
- dev-renovate/phpunit-phpunit-11.x
- dev-abstrac-api-fixes
- dev-abstract-database-constructor
- dev-did-you-mean-subtree
- dev-sf-54-logger
- dev-fix-di-config
- dev-renovate/vimeo-psalm-5.x
- dev-features-v1.5
- dev-renovate/codecov-3.x
- dev-upload-fix
- dev-fix-tag-content-trim
- dev-monolog-fix
- dev-Tests-JSON-Order-doesnt-matter
- dev-renovate/hgiesenow-php-8.x
- dev-matrix-jobs
This package is auto-updated.
Last update: 2024-11-21 23:11:33 UTC
README
This bundle provides reusable behat contexts for symfony applications. All steps are written in present tense, as suggested on https://automationpanda.com/2021/05/11/should-gherkin-steps-use-past-present-or-future-tense/
Features
- CommandContext to test symfony commands.
- DateContext to mock the current date.
- FormContext to test/manipulate/fill html forms.
- HtmlContext to check the DOM/plain HTTP response.
- HttpContext for simple HTTP interactions.
- JsonContext to send or check json data in request/response.
- LoggingContext to verify correct logging.
- MailerContext to check if mails were triggered.
- AbstractApiContext to help implementing custom context for external API interaction.
- AbstractDatabaseContext to help implementing custom context with database interaction.
Installation
Add to your composer requirements as dev dependency.
$ composer require --dev elbformat/symfony-behat-bundle
Activate bundle in your config/bundles.php
Elbformat\SymfonyBehatBundle\ElbformatSymfonyBehatBundle::class => ['test' => true],
Use contexts in your behat.yml
as you like
default: extensions: FriendsOfBehat\SymfonyExtension: bootstrap: tests/bootstrap.php kernel: path: src/Kernel.php class: App\Kernel environment: behat debug: false suites: default: contexts: - Elbformat\SymfonyBehatBundle\Context\CommandContext - Elbformat\SymfonyBehatBundle\Context\DateContext - Elbformat\SymfonyBehatBundle\Context\FormContext - Elbformat\SymfonyBehatBundle\Context\HtmlContext - Elbformat\SymfonyBehatBundle\Context\HttpContext - Elbformat\SymfonyBehatBundle\Context\JsonContext - Elbformat\SymfonyBehatBundle\Context\LoggingContext - Elbformat\SymfonyBehatBundle\Context\MailerContext
Mailer
To make the Test-Mailer work, you need to set the mailer dsn in config/packages/mailer.yaml
when@test:
framework:
mailer:
dsn: 'test://test'
API
To not send requests to a real api, you should configure the MockClient to be used in config/packages/framework.yaml
when@test:
framework:
http_client:
mock_response_factory: Elbformat\SymfonyBehatBundle\HttpClient\MockClientCallback
Examples
Examples can be found in dock/examples.md.
Updating
When updating from a previous version, see the changelog for changes.
What's next?
The next release should likely contain more tests/stability improvements.
Development
If you want to develop on the bundle you will find useful information in doc/development.md