定制 intraworlds/phpunit-db-fixtures 二次开发

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

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

intraworlds/phpunit-db-fixtures

最新稳定版本:0.8.1

Composer 安装命令:

composer require intraworlds/phpunit-db-fixtures

包简介

Loading DB fixtures with ease

README 文档

README

Simple DB fixtures loading, replacement for phpunit/dbunit

Usage

use IW\PHPUnit\DbFixtures\DbFixturesTrait;
use IW\PHPUnit\DbFixtures\Fixtures;

final class MyTest extends TestCase
{
  use DbFixturesTrait;

  // returns connections to your DB, implementation is up to you, a singleton should be returned probably
  protected function getConnections(string $connectionName): array {
    return match ($connectionName) {
      // key is name of DB, use it for distinction between multiple DBs
      'mysql' => new \PDO(...),
      'elastic' => new Elasticsearch\Client(...),
    };
  }

  #[Fixtures('mysql', 'read-only', 'fixtures.yml')]
  public function testWithFixtures() {
    // before test data from fixtures.yml will be loaded into mysql
  }
}

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-25