saeven/zf3-circlical-behat-fixtures
Composer 安装命令:
composer require saeven/zf3-circlical-behat-fixtures
包简介
Doctrine & Nelmio/Alice fixtures for Zend Framework 3 and Behat
README 文档
README
Trigger fixture loading from within Behat tests, like so:
Feature: I can define fixtures from within my tests
In order to keep my test database clean
As a developer writing behat tests
I want to load fixtures directly from within my test context
Scenario: Test loading a new fixture
Given fixture "Application/user" is loaded
And fixture "Application/user" is loaded
And fixtures "Application/user, Billing/invoices" are loaded
This package adds a behavior to alice, by way of automatically falling back onto reflection when a setter for a fixture-defined value is not available, and that value is nontrivial.
Highlights:
- fixtures provided by the excellent nelmio/alice
- comes with a ready-to-go context you can plug into Behat
- define what fixtures are required right at the Scenario level
- adds a convenient CLI command as well
Inspired by dkorsak/doctrine-data-fixture-module -- thanks!
Installation
- Composer install, then add
CirclicalBehatFixturesto your application.config.php
Wiring it into Behat
- Edit your behat.yml, to add the
CirclicalBehatFixtures\Behat\DatabaseContextcontext
e.g.
# behat.yml
default:
autoload: [ '%paths.base%/../contexts' ]
suites:
core_features:
paths: [ '%paths.base%/../features' ]
contexts:
- FeatureContext
- CirclicalBehatFixtures\Behat\DatabaseContext
Or, if you need to override the location of the Doctrine bin (where the symlink points to)
# behat.yml
default:
autoload: [ '%paths.base%/../contexts' ]
suites:
core_features:
paths: [ '%paths.base%/../features' ]
contexts:
- FeatureContext
- CirclicalBehatFixtures\Behat\DatabaseContext:
- vendor/doctrine/doctrine-module/bin/doctrine-module
Author a Fixture
The syntax for fixture identification is very simple, MODULE/fixturename. Examples:
- Application/user
- Application/roles
- Member/purchases
In your individual ZF modules, you will save your nelmio/alice fixtures as module/MODULE/user.yml. Examples based on fixture IDs above:
- module/Application/fixtures/user.yml
- module/Application/fixtures/roles.yml
- module/Member/fixtures/purchases.yml
Author a Scenario
Do this the way you usually would. The context provided by this module gives you a new action:
Given Fixture "FIXTUREID" is loaded
e.g.
Given Fixture "Application/user" is loaded
You can stack these as you need. The first one in a feature will auto-purge, the subsequent ones will append.
Container Support
If you need to import the fixture in a Docker command for example, perhaps as a part of a CI/CD chain, you'll need to change where the fixture gets loaded. In short, instead of this command:
vendor/bin/doctrine-module orm:fixtures:load --fixtures=Application/orders
You might need to run something like this command:
/usr/local/bin/docker container exec -w /code -i $(docker-compose ps -q php) php vendor/bin/doctrine-module orm:fixtures:load --fixtures=Application/orders
You can achieve this by outputting a prefix into a file with name circlical-fixtures-cmd-prefix, e.g. in your CI/CD scripts:
echo "/usr/local/bin/docker container exec -w /code -i $(docker-compose ps -q php) " > ./circlical-fixtures-cmd-prefix
It becomes your responsibility to create (at startup) and delete (at tear-down) this file in your CI chain configuration.
saeven/zf3-circlical-behat-fixtures 适用场景与选型建议
saeven/zf3-circlical-behat-fixtures 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.69k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 02 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「fixtures」 「Behat」 「doctrine」 「Zend Framework」 「alice」 「zf3」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 saeven/zf3-circlical-behat-fixtures 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 saeven/zf3-circlical-behat-fixtures 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 saeven/zf3-circlical-behat-fixtures 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Behat Context for testing Symfony Api
A Behat Extension that allows custom bootstrapping
Environment processor and contexts autoloader
Provides access to magento2 object manager from behat and allows to change magento config settings temporarly
Testing object factory for PHP
Testing object factory for PHP
统计信息
- 总下载量: 9.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MPL-2.0
- 更新时间: 2020-02-28