Skip to content

Commit b7e7407

Browse files
committed
Release version 1.0.0
1 parent c549d5f commit b7e7407

File tree

8 files changed

+1087
-2
lines changed

8 files changed

+1087
-2
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Nick Tsai
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 140 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,140 @@
1-
# codeigniter-phpunit
2-
CodeIgniter 3 PHPUnit test library
1+
<p align="center">
2+
<a href="https://codeigniter.com/" target="_blank">
3+
<img src="https://codeigniter.com/assets/images/ci-logo-big.png" height="100px">
4+
</a>
5+
<h1 align="center">CodeIgniter PHPUnit Test</h1>
6+
<br>
7+
</p>
8+
9+
CodeIgniter 3 PHPUnit Test extension library
10+
11+
[![Latest Stable Version](https://poser.pugx.org/yidas/codeigniter-phpunit/v/stable?format=flat-square)](https://packagist.org/packages/yidas/codeigniter-phpunit)
12+
[![Latest Unstable Version](https://poser.pugx.org/yidas/codeigniter-phpunit/v/unstable?format=flat-square)](https://packagist.org/packages/yidas/codeigniter-phpunit)
13+
[![License](https://poser.pugx.org/yidas/codeigniter-phpunit/license?format=flat-square)](https://packagist.org/packages/yidas/codeigniter-phpunit)
14+
15+
FEATURES
16+
--------
17+
18+
- ***PHPUnit Test** in **Codeigniter 3** Framework*
19+
20+
- *Easy to install into your Codeigniter project by Composer*
21+
22+
---
23+
24+
OUTLINE
25+
-------
26+
27+
- [Requirements](#requirements)
28+
- [Installation](#installation)
29+
- [Directory Structure](#directory-structure)
30+
- [Configuration](#configuration)
31+
- [Usage](#usage)
32+
- [Test Case](#test-case)
33+
34+
35+
REQUIREMENTS
36+
------------
37+
38+
This library requires the following:
39+
40+
- PHP 5.3.0+
41+
- CodeIgniter 3.0.0+
42+
43+
---
44+
45+
INSTALLATION
46+
------------
47+
48+
Run Composer in your Codeigniter project under the folder `\application`:
49+
50+
composer require yidas/codeigniter-phpunit
51+
52+
---
53+
54+
DIRECTORY STRUCTURE
55+
-------------------
56+
57+
```
58+
codeigniter/
59+
└── application/
60+
├── tests/ Test cases
61+
├── vendor/ Vendor included yidas/codeigniter-phpunit
62+
└── phpunit.xml PHPUnit XML
63+
```
64+
65+
---
66+
67+
CONFIGURATION
68+
-------------
69+
70+
According to [Directory Structure](#directory-structure), create and configure `phpunit.xml` under `application` directory:
71+
72+
```xml
73+
<?xml version="1.0" encoding="UTF-8" ?>
74+
<phpunit bootstrap="vendor/yidas/codeigniter-phpunit/bootstrap.php">
75+
<testsuites>
76+
<testsuite name="TestSuite">
77+
<directory>tests</directory>
78+
</testsuite>
79+
</testsuites>
80+
</phpunit>
81+
```
82+
83+
For this `phpunit.xml` template, the test cases directory is `application/test`, make sure you would create every test cases under it.
84+
85+
---
86+
87+
USAGE
88+
-----
89+
90+
In the `application` directory of this library, run `phpunit` from vendor:
91+
92+
```
93+
./vendor/bin/phpunit
94+
```
95+
96+
Then the result would like:
97+
98+
```
99+
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
100+
101+
102+
103+
Time: 40 ms, Memory: 2.75MB
104+
105+
No tests executed!
106+
```
107+
108+
---
109+
110+
TEST CASE
111+
---------
112+
113+
With this extension libaray, you could write test cases with loading Codeigniter framework.
114+
115+
For example, write a test case `application/tests/CodeigniterTest.php` for testing Codeigniter config component:
116+
117+
```php
118+
<?php
119+
120+
use PHPUnit\Framework\TestCase;
121+
122+
final class CodeigniterTest extends TestCase
123+
{
124+
function __construct()
125+
{
126+
parent::__construct();
127+
// Load CI application
128+
$this->CI = & get_instance();
129+
}
130+
131+
public function testConfigItem()
132+
{
133+
$indexPage = $this->CI->config->item('index_page');
134+
135+
$this->assertSame('index.php', $indexPage);
136+
}
137+
}
138+
```
139+
140+
Then you would get the result `OK (1 test, 1 assertion)` by running PHPUnit test.

0 commit comments

Comments
 (0)