fit2in / symfony-behat-authenticator
此包最新版本(3.1.0)没有可用的许可证信息。
3.1.0
2022-10-11 09:01 UTC
Requires
- doctrine/doctrine-bundle: ^2.5
- doctrine/orm: ^2.10
- symfony/framework-bundle: ^6.0
Requires (Dev)
- behat/behat: ^3.10
- fittinq/symfony-behat-services: ^1.0
- friends-of-behat/mink: ^1.10
- friends-of-behat/mink-extension: ^2.6
- friends-of-behat/symfony-extension: ^2.3
- phpunit/phpunit: ^9.5
- symfony/yaml: ^6.1
README
Symfony Behat Authenticator Bundle 是一个强大的工具,它简化了为您的 Symfony 应用程序编写 Behat 测试的过程。它提供 Behat 上下文和服务,以帮助测试用户身份验证、角色和前端交互。
目录
安装
您可以使用 Composer 安装此包
composer require fittinq/symfony-behat-authenticator
配置
更新您的项目以在测试设置中包含 Behat 包。
default:
default:
paths:
- behat/features
contexts:
- Fittinq\Symfony\Behat\Authenticator\Context\AuthenticatorApiContext
- Fittinq\Symfony\Behat\Authenticator\Context\AuthenticatorDatabaseContext
- Fittinq\Symfony\Behat\Authenticator\Context\AuthenticatorUserContext
- Fittinq\Symfony\Behat\Authenticator\Context\AuthenticatorRoleContext
- Fittinq\Symfony\Behat\Authenticator\Context\AuthenticatorFrontendContext
用法
AuthenticatorRoleContext
此上下文专注于管理角色,包括添加角色和验证其存在的步骤。
示例用法
Given there are roles
| name |
| ROLE_USER |
| ROLE_ADMIN |
| ROLE_EDITOR|
AuthenticatorUserContext
此上下文设计用于管理与用户相关的 Behat 步骤。它包括添加用户和通过 API 进行身份验证的步骤。
示例用法
Given there are users
| username | password | roles |
| user1 | secret | ROLE_USER |
| admin | password | ROLE_ADMIN |
| editor | 123456 | ROLE_EDITOR |
AuthenticatorFrontendContext
AuthenticatorFrontendContext 用于测试前端交互,例如用户登录,并检查 HTTP 状态码和页面内容。
示例用法
Given user user1 logs in to the frontend app
Then the current page should contain text "Welcome, user1!"