定制 roave/behat-psr11extension 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

roave/behat-psr11extension

Composer 安装命令:

composer require roave/behat-psr11extension

包简介

PSR-11 Container extension for Behat

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version License

Allows injecting services from a PSR-11-compatibile container in a Behat context.

Created with lots of help from @ciaranmcnulty.

Usage

First require the extension and dependencies with Composer:

$ composer require --dev roave/behat-psr11extension

First, if you don't already have one, create a file that will be included by the extension that returns a PSR-11 compatible container, for example using Laminas\ServiceManager:

<?php
declare(strict_types=1);

use Laminas\ServiceManager\Config;
use Laminas\ServiceManager\ServiceManager;

// Load configuration
$config = require __DIR__ . '/config.php';

// Build container
$container = new ServiceManager();
(new Config($config['dependencies']))->configureServiceManager($container);

// Inject config
$container->setService('config', $config);

return $container;

Then enable the extension in behat.yml:

  extensions:
    Roave\BehatPsrContainer\PsrContainerExtension:
      container: 'config/container.php'

Then enable the use of the psr_container service container (this is provided by the extension) in your behat.yml suite configuration, for example:

default:
  suites:
    my_suite:
      services: "@psr_container"

And finally, add the names of any services required by your contexts in behat.yml, for example:

default:
  suites:
    my_suite:
      services: "@psr_container"
      contexts:
        - MyBehatTestSuite\MyContext:
          - "@Whatever\\Service\\Name"

You can also use behat's built-in autowire feature, to automatically inject the dependencies to the context:

default:
  suites:
    my_suite:
      autowire: true
      services: "@psr_container"
      contexts:
        - MyBehatTestSuite\MyContext

If for some reason you want to use a name other than psr_container for the container (e.g. collision with another extension) this can be overridden:

  extensions:
    Roave\BehatPsrContainer\PsrContainerExtension:
      container: 'config/container.php'
      name: 'my_container'

Just for clarity (and hopefully ease of understanding), this would be the equivalent of doing this in plain PHP:

<?php
declare(strict_types=1);

$container = require 'config/container.php';

$context = new \MyBehatTestSuite\MyContext($container->get('Whatever\Service\Name'));

roave/behat-psr11extension 适用场景与选型建议

roave/behat-psr11extension 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 349.97k 次下载、GitHub Stars 达 41, 最近一次更新时间为 2017 年 08 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 roave/behat-psr11extension 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 roave/behat-psr11extension 我们能提供哪些服务?
定制开发 / 二次开发

基于 roave/behat-psr11extension 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 349.97k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 41
  • 点击次数: 17
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 41
  • Watchers: 9
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-09