foogile / elgg-phpunit

PHPUnit 设置以支持与 Elgg 的集成测试。

v0.0.3 2015-04-15 17:07 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:43:45 UTC


README

简单的测试配置,以支持在 Elgg 中使用 PHPUnit 进行集成测试。假设 Elgg 1.9 的默认目录结构。

安装

使用 composer 将测试配置安装到您的插件中

composer require foogile/elgg-phpunit

用法

有三个默认的 PHPUnit 配置可供使用,可以运行所有单元测试、所有集成测试或所有测试。单元测试位于 PLUGIN/tests/unit,集成测试位于 PLUGIN/tests/integration。您可以通过创建名为 PLUGIN/tests/integration/settings.php 的文件来修改测试环境的 Elgg 配置。

引导

您可以通过创建 PLUGIN/tests/integration/bootstrap.phpPLUGIN/tests/unit/bootstrap.php 来运行自定义初始化代码,分别用于集成测试和单元测试。此外,PLUGIN/tests/bootstrap.php 在所有情况下都会首先加载。

运行单元测试

phpunit -c vendor/foogile/elgg-phpunit/phpunit.unit.xml

运行集成测试

phpunit -c vendor/foogile/elgg-phpunit/phpunit.integration.unit.xml

运行所有测试

phpunit -c vendor/foogile/elgg-phpunit/phpunit.xml

Elgg 安装助手

包含了一个实用脚本来安装 Elgg 测试环境。要初始化数据库,请在 PLUGIN/tests/integration/settings.php 中指定您的数据库设置,并从插件的根目录执行以下命令

php vendor/foogile/elgg-phpunit/install.php