matthiasnoback/doctrine-orm-test-service-provider 问题修复 & 功能扩展

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

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

matthiasnoback/doctrine-orm-test-service-provider

Composer 安装命令:

composer require matthiasnoback/doctrine-orm-test-service-provider

包简介

Service provider for tests in need of a Doctrine entity manager

README 文档

README

CI

This library contains a service provider to be used with a service container for PHPUnit tests.

Usage

Use the trait Noback\PHPUnitTestServiceContainer\PHPUnit\TestCaseWithEntityManager in your test class. You then need to implement the getEntityDirectories() which should return an array of the directories containing the entities that should be loaded.

For each test method a connection to an SQLite database will be available. Also the schema for the given entities will be created automatically.

<?php

use PHPUnit\Framework\TestCase;
use Noback\PHPUnitTestServiceContainer\PHPUnit\TestCaseWithEntityManager;

class StorageTest extends TestCase 
{
    use TestCaseWithEntityManager;
    
    protected function getEntityDirectories(): array
    {
        return array(
            __DIR__ . '/Entity'
        );
    }

    /**
     * @test
     */
    public function it_persists_an_entity()
    {
        $user = new User();
        $user->setName('Matthias');

        $this->getEntityManager()->persist($user);
        $this->getEntityManager()->flush();
    }
}

Of course, you would usually inject the entity manager into some object which is the subject-under-test.

To register Doctrine event listeners/subscribers, get the EventManager instance by calling $this->getEventManager(). To get the database Connection object, call $this->getConnection().

Read more

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-12-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固