nojimage/cakephp-test-datasource-switcher 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

nojimage/cakephp-test-datasource-switcher

最新稳定版本:v1.0.1

Composer 安装命令:

composer require nojimage/cakephp-test-datasource-switcher

包简介

TestDatasourceSwitcher plugin for CakePHP 3

README 文档

README

Software License Build Status Codecov Latest Stable Version

Switching datasouce connections to test, when the request have a specific Cookie.

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require --dev nojimage/cakephp-test-datasource-switcher

CakePHP >= 3.3 in src/Application.php

    public function middleware($middlewareQueue)
    {
        $middlewareQueue
            // Catch any exceptions in the lower layers,
            // and make an error page/response
            ->add(ErrorHandlerMiddleware::class)

            // vvv ADD THIS LINE vvv
            ->add(new \TestDatasourceSwitcher\Middleware\DatasourceSwitchMiddleware())

            // Handle plugin/theme assets like CakePHP normally does.
            ->add(AssetMiddleware::class)

            // Add routing middleware.
            ->add(new RoutingMiddleware($this));

        return $middlewareQueue;
    }

CakePHP <= 3.2 in config/bootstrap.php

if (Configure::read('debug')) {
    \Cake\Routing\DispatcherFactory::add(new \TestDatasourceSwitcher\Routing\Filter\Switcher(['priority' => 1]));
}

Usage

eg. For the Codeception functional testcases.
(This sample is always connect to 'test' datasouces.

class FunctionalHelper extends \Codeception\Module
{

    public function _before(TestCase $test)
    {
        $driver = $this->getModule('WebDriver');
        /* @var $dirver WebDriver */
        $driver->amOnPage('/');
        $driver->setCookie('__cakephp_test_connection', '1');
    }

(...snip...) 

License

This software is released under the MIT License.

Copyright (c) 2015 ELASTIC Consultants Inc. https://elasticconsultants.com/

http://opensource.org/licenses/mit-license.php

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-23