承接 peridot-php/peridot-httpkernel-plugin 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

peridot-php/peridot-httpkernel-plugin

Composer 安装命令:

composer require peridot-php/peridot-httpkernel-plugin

包简介

A Peridot plugin to simplify testing HttpKernel applications

README 文档

README

Build Status HHVM Status

Easily test HttpKernel applications with Peridot.

Some HttpKernel based frameworks:

##Usage

We recommend installing this plugin to your project via composer:

$ composer require --dev peridot-php/peridot-httpkernel-plugin:~1.0

You can register the plugin via your peridot.php file.

<?php
use Evenement\EventEmitterInterface;
use Peridot\Plugin\HttpKernel\HttpKernelPlugin;

return function(EventEmitterInterface $emitter) {
    //the second argument expects an HttpKernelInterface or a function that returns one
    HttpKernelPlugin::register($emitter, include __DIR__ . '/app.php');
};

By registering the plugin, your Peridot tests will now have a $client property available:

<?php
describe('Api', function() {
    describe('/info', function() {
        it('should return info about Peridot', function() {
            $this->client->request('GET', '/info');
            $response = $this->client->getResponse();
            $info = json_decode($response->getContent());
            assert($info->project == "Peridot", "project should be Peridot");
            assert($info->description == "Event driven testing framework", "description should describe Peridot");
            assert($info->styles == "BDD, TDD", "styles should be BDD, TDD");
        });
    });

    describe('/author', function() {
        it('should return info about the author', function() {
            $this->client->request('GET', '/author');
            $author = json_decode($this->client->getResponse()->getContent());
            assert($author->name == "Brian Scaturro", "author name should be on response");
            assert($author->likes == "pizza", "author should like pizza");
        });
    });
});

Voilà!

Don't want a client in all of your tests? No problem.

###Using on a test by test basis

Like any other peridot scope, you can mix the HttpKernelScope provided by this plugin on a test by test, or suite by suite basis.

<?php
use Peridot\Plugin\HttpKernel\HttpKernelScope;

describe('Api', function() {

    //here we manually mixin the http kernel scope
    $scope = new HttpKernelScope(include __DIR__ . '/../app.php');
    $this->peridotAddChildScope($scope);

    describe('/author', function() {
        it('should return info about the author', function() {
            $this->client->request('GET', '/author');
            $author = json_decode($this->client->getResponse()->getContent());
            assert($author->name == "Brian Scaturro", "author name should be on response");
            assert($author->likes == "pizza", "author should like pizza");
        });
    });
});

###Configuring the client property name

If $this->client is a little too generic for your tastes, both the scope and plugin take an optional last argument that allows you to you set this.

HttpKernelPlugin::register($emitter, include __DIR__ . '/app.php', "browser");
$scope = new HttpKernelScope($application, "browser");

Your tests now become:

<?php
use Peridot\Plugin\HttpKernel\HttpKernelScope;

describe('Api', function() {

    describe('/author', function() {
        it('should return info about the author', function() {
            $this->browser->request('GET', '/author');
            $author = json_decode($this->browser->getResponse()->getContent());
            assert($author->name == "Brian Scaturro", "author name should be on response");
            assert($author->likes == "pizza", "author should like pizza");
        });
    });
});

##Example specs

This repo comes with a sample Silex application that is tested with this plugin.

To test examples that are using the plugin, run the following:

$ vendor/bin/peridot -c app/peridot.php app/specs/api.spec.php

To test examples that are manually adding the scope in, run this:

$ vendor/bin/peridot app/specs/no-plugin.spec.php

##Running plugin tests

$ vendor/bin/peridot specs/

peridot-php/peridot-httpkernel-plugin 适用场景与选型建议

peridot-php/peridot-httpkernel-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.43k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2014 年 10 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 peridot-php/peridot-httpkernel-plugin 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 7.43k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-10-23