PHPackages                             edgcarmu/codeigniter-phpunit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. edgcarmu/codeigniter-phpunit

ActiveLibrary[Testing &amp; Quality](/categories/testing)

edgcarmu/codeigniter-phpunit
============================

Official adaptation of yidas/codeigniter-phpunit for CodeIgniter 3.1.11 and PHP 7.1+

v1.0.0(11mo ago)0569—0%MITPHP

Since Jun 9Pushed 11mo agoCompare

[ Source](https://github.com/edgcarmu/codeigniter-phpunit)[ Packagist](https://packagist.org/packages/edgcarmu/codeigniter-phpunit)[ Docs](https://github.com/edgcarmu/codeigniter-phpunit)[ RSS](/packages/edgcarmu-codeigniter-phpunit/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

 [ ![](https://camo.githubusercontent.com/7040d7395e52bcf95f4482b9ad6d5ca99fa7340041694e6885835ea2bd0a38c3/68747470733a2f2f636f646569676e697465722e636f6d2f6173736574732f69636f6e732f63692d6c6f676f2e706e67) ](https://codeigniter.com/)CodeIgniter PHPUnit Test
========================

[](#codeigniter-phpunit-test)

CodeIgniter 3 PHPUnit Test extension library

[![Latest Stable Version](https://camo.githubusercontent.com/79afd75999f002b38887a069231df50600695d05df4694187618188142efb784/68747470733a2f2f706f7365722e707567782e6f72672f6564676361726d752f636f646569676e697465722d706870756e69742f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/edgcarmu/codeigniter-phpunit)[![License](https://camo.githubusercontent.com/a2b0b8fe2d83e937fb79eb8702332bccb7240c4e1abb107c2c69a5624d85605a/68747470733a2f2f706f7365722e707567782e6f72672f6564676361726d752f636f646569676e697465722d706870756e69742f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/edgcarmu/codeigniter-phpunit)

Official adaptation of the [yidas/codeigniter-phpunit](https://github.com/yidas/codeigniter-phpunit) repository for compatibility with **CodeIgniter 3.1.13** and **PHP 7.1+**.

FEATURES
--------

[](#features)

- ***PHPUnit Test** in **Codeigniter 3** Framework*
- *Easy to install into your Codeigniter project by Composer*

---

OUTLINE
-------

[](#outline)

- [Requirements](#requirements)
- [Installation](#installation)
- [Directory Structure](#directory-structure)
- [Configuration](#configuration)
- [Usage](#usage)
- [Test Case](#test-case)

REQUIREMENTS
------------

[](#requirements)

This library requires the following:

- PHP 7.1.0+
- CodeIgniter 3.1.13+

---

INSTALLATION
------------

[](#installation)

Run Composer from the project root:

```
composer require edgcarmu/codeigniter-phpunit

```

---

DIRECTORY STRUCTURE
-------------------

[](#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
-------------

[](#configuration)

According to [Directory Structure](#directory-structure), create and configure `phpunit.xml` in the project root:

```

      tests

```

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
-----

[](#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
---------

[](#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:

```
