Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yidas/codeigniter-phpunit
CodeIgniter 3 PHPUnit Test extension library
https://github.com/yidas/codeigniter-phpunit
codeigniter phpunit test-driven-development unit-test
Last synced: 4 months ago
JSON representation
CodeIgniter 3 PHPUnit Test extension library
- Host: GitHub
- URL: https://github.com/yidas/codeigniter-phpunit
- Owner: yidas
- License: mit
- Created: 2018-04-26T07:25:15.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-23T06:57:16.000Z (almost 6 years ago)
- Last Synced: 2024-09-30T07:22:11.385Z (4 months ago)
- Topics: codeigniter, phpunit, test-driven-development, unit-test
- Language: PHP
- Homepage:
- Size: 9.77 KB
- Stars: 16
- Watchers: 1
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
CodeIgniter PHPUnit Test
CodeIgniter 3 PHPUnit Test extension library
[![Latest Stable Version](https://poser.pugx.org/yidas/codeigniter-phpunit/v/stable?format=flat-square)](https://packagist.org/packages/yidas/codeigniter-phpunit)
[![License](https://poser.pugx.org/yidas/codeigniter-phpunit/license?format=flat-square)](https://packagist.org/packages/yidas/codeigniter-phpunit)This RESTful API extension is collected into [yidas/codeigniter-pack](https://github.com/yidas/codeigniter-pack) which is a complete solution for Codeigniter framework.
FEATURES
--------- ***PHPUnit Test** in **Codeigniter 3** Framework*
- *Easy to install into your Codeigniter project by Composer*
---
OUTLINE
-------- [Requirements](#requirements)
- [Installation](#installation)
- [Directory Structure](#directory-structure)
- [Configuration](#configuration)
- [Usage](#usage)
- [Test Case](#test-case)REQUIREMENTS
------------This library requires the following:
- PHP 5.3.0+
- CodeIgniter 3.0.0+---
INSTALLATION
------------Run Composer in your Codeigniter project under the folder `\application`:
composer require yidas/codeigniter-phpunit
---
DIRECTORY STRUCTURE
-------------------```
codeigniter/
└── application/
├── tests/ Test cases
├── vendor/ Vendor included yidas/codeigniter-phpunit
└── phpunit.xml PHPUnit XML
```---
CONFIGURATION
-------------According to [Directory Structure](#directory-structure), create and configure `phpunit.xml` under `application` directory:
```xml
tests
```
For this `phpunit.xml` template, the test cases directory is `application/test`, make sure you would create every test cases under it.
---
USAGE
-----In the `application` directory of this library, run `phpunit` from vendor:
```
$ ./vendor/bin/phpunit
```Or using absolute path commands like:
```
$ /var/www/html/codeigniter3/application/vendor/bin/phpunit -c /var/www/html/codeigniter3/application/phpunit.xml
$ phpunit -c /var/www/html/codeigniter3/application/phpunit.xml
```Then the result would like:
```ps
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.Time: 40 ms, Memory: 2.75MB
No tests executed!
```---
TEST CASE
---------With this extension libaray, you could write test cases with loading Codeigniter framework.
For example, write a test case `application/tests/CodeigniterTest.php` for testing Codeigniter config component:
```php
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.