phariscope / doctrine-testing-tools
一个用于测试 Doctrine 仓库的 PHP 组件
v1.3.8
2024-06-11 10:07 UTC
Requires
- php: >=8.1
- doctrine/doctrine-bundle: ^2
- doctrine/orm: ^2|^3
- symfony/dotenv: ^6|^7.0
- symfony/framework-bundle: ^6|^7.0
- symfony/http-kernel: ^6|^7.0
- symfony/runtime: ^6|^7.0
- symfony/yaml: ^6|^7.0
Requires (Dev)
- infection/extension-installer: 0.1.2
- infection/infection: ^0.27
- phpstan/phpdoc-parser: ^1.20
- phpstan/phpstan: 1.10.15
- phpunit/phpunit: ^10
- squizlabs/php_codesniffer: 3.*
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'