funk-spec/symfony-extension
Composer 安装命令:
composer require funk-spec/symfony-extension
包简介
extension that helps using your symfony application's services in your tests
README 文档
README
composer require --dev funk-spec/symfony-extension
What ?
A funk-spec extension that integrates your symfony application with your specs.
It will:
- resolve constructor arguments typehinted with
ContainerInterface - wrap each example with a doctrine transaction and rollback afterwards
Why ?
For the same exact reason than the behat's one exists.
Both are relying on the TestWork framework.
Unfortunately, a lot of duplication exists between both, but no real tentative has been done yet
to abstract away the few differences.
How ?
In your funk.yml:
default: autoload: tests: '%paths.base%' suites: default: ~ extensions: FunkSpec\Extension\Symfony\Extension: kernel: class: App\Symfony\Kernel # or AppKernel (must be autoloadable) env: test
Now your spec classes can have the container injected:
<?php namespace tests\Doctrine\Repository; use Symfony\Component\DependencyInjection\ContainerInterface; final class Products implements \Funk\Spec { public function __construct(ContainerInterface $container) { $this->products = $container->get('products'); // this is a repository } function it_works() { $this->products->find('77c4bb2e-2c18-4164-a899-7f969dec5c9d')->getId(); } }
automatic transaction wrapping and rollback
Every example is ran in a transaction and rollbacked after each execution, except if you explicitely disable it:
default: extensions: FunkSpec\Extension\Symfony\Extension: doctrine: rollback: false
This depends on the presence of a doctrine service in the application Kernel, insanceof ManagerRegistry.
funk-spec/symfony-extension 适用场景与选型建议
funk-spec/symfony-extension 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22.65k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 09 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 funk-spec/symfony-extension 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 funk-spec/symfony-extension 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 22.65k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-29