edgcarmu/codeigniter-phpunit
Composer 安装命令:
composer require edgcarmu/codeigniter-phpunit
包简介
Official adaptation of yidas/codeigniter-phpunit for CodeIgniter 3.1.11 and PHP 7.1+
README 文档
README
CodeIgniter PHPUnit Test
CodeIgniter 3 PHPUnit Test extension library
Official adaptation of the yidas/codeigniter-phpunit repository for compatibility with CodeIgniter 3.1.13 and PHP 7.1+.
FEATURES
-
PHPUnit Test in Codeigniter 3 Framework
-
Easy to install into your Codeigniter project by Composer
OUTLINE
REQUIREMENTS
This library requires the following:
- PHP 7.1.0+
- CodeIgniter 3.1.13+
INSTALLATION
Run Composer from the project root:
composer require edgcarmu/codeigniter-phpunit
DIRECTORY STRUCTURE
codeigniter/
├── application/
├── system/
├── tests/
│ ├── bootstrap.php ← Initializes the test environment; create only if needed to customize, then delegate to vendor/edgcarmu/codeigniter-phpunit/bootstrap.php
│ └── MyTest.php ← Your test cases go here
├── vendor/
└── phpunit.xml ← PHPUnit configuration; can point directly to the library's bootstrap if no customization is needed
CONFIGURATION
According to Directory Structure, create and configure phpunit.xml in the project root:
<?xml version="1.0" encoding="UTF-8" ?> <phpunit bootstrap="vendor/edgcarmu/codeigniter-phpunit/bootstrap.php"> <testsuites> <testsuite name="TestSuite"> <directory>tests</directory> </testsuite> </testsuites> </phpunit>
For this phpunit.xml template, the test cases directory is tests/, located at the project root. Make sure to place all your test cases inside this directory.
USAGE
From the project root, run PHPUnit using the Composer-installed binary:
./vendor/bin/phpunit
Or using absolute path commands like:
$ /var/www/html/codeigniter3/vendor/bin/phpunit -c /var/www/html/codeigniter3/phpunit.xml
$ phpunit -c /var/www/html/codeigniter3/phpunit.xml
Then the result would like:
PHPUnit 5.7.27 by Sebastian Bergmann and contributors. Time: 40 ms, Memory: 2.75MB No tests executed!
TEST CASE
With this extension library, you can write test cases while loading the CodeIgniter framework.
For example, create a test case at tests/CodeigniterTest.php to test a CodeIgniter component like the config loader:
<?php use PHPUnit\Framework\TestCase; final class CodeigniterTest extends TestCase { function __construct() { parent::__construct(); // Load CI application $this->CI = & get_instance(); } public function testConfigItem() { $indexPage = $this->CI->config->item('index_page'); $this->assertSame('index.php', $indexPage); } }
Then you would get the result OK (1 test, 1 assertion) by running PHPUnit test.
edgcarmu/codeigniter-phpunit 适用场景与选型建议
edgcarmu/codeigniter-phpunit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 762 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「phpunit」 「codeigniter」 「unit-test」 「test-driven-development」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 edgcarmu/codeigniter-phpunit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 edgcarmu/codeigniter-phpunit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 edgcarmu/codeigniter-phpunit 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
HiDev plugin for PHPUnit
Testing Suite For Lumen like Laravel does.
A cli tool which generates unit tests.
Arcanist util to run tests and generate code coverage reports for phpunit7 format.
The CodeIgniter Redis package
PMVC Test Framework
统计信息
- 总下载量: 762
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-08