phariscope/doctrine-testing-tools

一个用于测试 Doctrine 仓库的 PHP 组件

v1.3.8 2024-06-11 10:07 UTC

This package is auto-updated.

Last update: 2024-09-11 10:43:14 UTC


README

一个帮助测试 Doctrine SQL 仓库的 PHP 组件。

为了减少处理时间,此组件将仅使用 SQL 查询删除请求的表。我只在 MySQL 和 SQLite 数据库上使用它,因此我不需要此组件与其他解决方案协同工作。

用法

要使用此组件,您需要

  • DoctrineRepositoryTesterTrait 添加到每个 doctrine 仓库测试中。
  • setUp() 中,调用 $this->initDoctrineTester() 以初始化测试器。现在您可以通过以下方式访问
    • clearTables(array $tablesToClear) 来清除您想要清除的每个表。
    • getEntityManager() 来访问您仓库的 EntityManagerInterface 实例。

查看 ExempleRepositoryDoctrine 以获取示例。

安装

composer require --dev phariscope/doctrine-testing-tools

为 Doctrine 测试工具做出贡献

要求

  • docker
  • git

单元测试

bin/phpunit

集成测试

bin/phpunit-integration

质量

一些指标

  • phpcs PSR12
  • phpstan 级别 9
  • 覆盖率 >= 100%
  • infection MSI >= 100%

使用

./codecheck

使用

bin/phpunit --coverage-html var

检查覆盖率,并在浏览器中查看 'var/index.html'

使用

bin/infection

检查感染,并在浏览器中查看 'var/infection.html'