Skip to content

Commit 96358be

Browse files
committed
Update docs for release
1 parent 5a7b059 commit 96358be

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ An easier way to use PHPUnit with [CodeIgniter](https://github.com/bcit-ci/CodeI
1919

2020
* PHP 5.4.0 or later (5.6 or later is recommended)
2121
* CodeIgniter 3.x
22-
* PHPUnit 4.3 or later (4.7 or later is recommended)
23-
* If you use NetBeans 8.0.2, please use 4.7. 4.8 is not compatible yet. You can download old version of `phpunit.phar` from <https://phar.phpunit.de/>.
22+
* PHPUnit 4.3 or later (4.8 or later is recommended)
23+
* If you use PHPUnit 6.0, please use ci-phpunit-test v0.14.0 or later.
24+
* You can download old version of `phpunit.phar` from <https://phar.phpunit.de/>.
2425

2526
## Optional
2627

application/tests/_ci_phpunit_test/ChangeLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change Log for ci-phpunit-test
22

3-
## v0.14.0 (Not Released)
3+
## v0.14.0 (2017/02/09)
44

55
### Upgrade Note for PHPUnit 6.0 users
66

docs/HowToWriteTests.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class Inventory_model_test extends TestCase
260260

261261
[$this->newModel()](FunctionAndClassReference.md#testcasenewmodelclassname) method in ci-phpunit-test is a helper method to reset CodeIgniter instance and create new model instance.
262262

263-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/models/Category_model_test.php).
263+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/models/Category_model_test.php).
264264

265265
#### Database Seeding
266266

@@ -281,7 +281,7 @@ You can use them like below:
281281
}
282282
~~~
283283

284-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/models/Category_model_test.php).
284+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/models/Category_model_test.php).
285285

286286
#### Using PHPUnit Mock Objects
287287

@@ -344,7 +344,7 @@ If you don't know well about PHPUnit Mock Objects, see [Test Doubles](https://ph
344344
}
345345
~~~
346346

347-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/models/Category_model_mocking_db_test.php).
347+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/models/Category_model_mocking_db_test.php).
348348

349349
### Libraries
350350

@@ -384,7 +384,7 @@ You can use [$this->request()](FunctionAndClassReference.md#testcaserequestmetho
384384

385385
**Note:** If you pass URI string to the 2nd argument of `$this->request()`, it invokes the routing. If the resolved controller has `_remap()` and/or `_output()` methods, they will be invoked, too.
386386

387-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/sub/Sub_test.php).
387+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/sub/Sub_test.php).
388388

389389
If you want to call a controller method directly, you can pass an array to the 2nd argument of `$this->request()`.
390390

@@ -404,7 +404,7 @@ class Welcome_test extends TestCase
404404

405405
**Note:** If you pass an array to the 2nd argument of `$this->request()`, it does not invokes the routing. The `_remap()` and/or `_output()` methods in a controller are not invoked, too.
406406

407-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Welcome_test.php).
407+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Welcome_test.php).
408408

409409
#### REST Request
410410

@@ -442,7 +442,7 @@ You can set request header with [$this->request->setHeader()](FunctionAndClassRe
442442
}
443443
~~~
444444

445-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/api/Example_test.php).
445+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/api/Example_test.php).
446446

447447
#### Ajax Request
448448

@@ -457,7 +457,7 @@ You can use [$this->ajaxRequest()](FunctionAndClassReference.md#testcaseajaxrequ
457457
}
458458
~~~
459459

460-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Ajax_test.php).
460+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Ajax_test.php).
461461

462462
#### Request and Use Mocks
463463

@@ -487,7 +487,7 @@ You can use [$this->request->setCallable()](FunctionAndClassReference.md#request
487487

488488
**Note:** When you have not loaded a class with CodeIgniter loader, if you make a mock object for the class, your application code may not work correclty. If you have got an error, please try to load it with CodeIgniter loader, before getting the mock object.
489489

490-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Mock_phpunit_test.php).
490+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Mock_phpunit_test.php).
491491

492492
The function you set by `$this->request->setCallable()` runs after controller instantiation. So you can't inject mocks into controller constructor.
493493

@@ -537,7 +537,7 @@ In this case, You can use [$this->request->setCallablePreConstructor()](Function
537537
}
538538
~~~
539539

540-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Auth_check_in_construct_test.php).
540+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Auth_check_in_construct_test.php).
541541

542542
**Note:** If you can't create mocks or it is too hard to create mocks, it may be better to use Monkey Patching.
543543

@@ -601,7 +601,7 @@ I recommend using PHPUnit mock objects. [$this->getDouble()](FunctionAndClassRef
601601
}
602602
~~~
603603

604-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Auth_test.php).
604+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Auth_test.php).
605605

606606
#### `redirect()`
607607

@@ -621,7 +621,7 @@ If you use `redirect()` in ci-phpunit-test, you can write tests like this:
621621

622622
[$this->assertRedirect()](FunctionAndClassReference.md#testcaseassertredirecturi-code--null) is a method in ci-phpunit-test.
623623

624-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Redirect_test.php).
624+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Redirect_test.php).
625625

626626
##### Upgrade Note for v0.4.0
627627

@@ -663,7 +663,7 @@ You can use [$this->assertResponseCode()](FunctionAndClassReference.md#testcasea
663663
}
664664
~~~
665665

666-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Nocontroller_test.php).
666+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Nocontroller_test.php).
667667

668668
If you don't call `$this->request()` in your tests, `show_error()` throws `CIPHPUnitTestShowErrorException` and `show_404()` throws `CIPHPUnitTestShow404Exception`. So you must expect the exceptions. You can use `@expectedException` annotation in PHPUnit.
669669

@@ -713,7 +713,7 @@ If you want to enable hooks, call [$this->request->enableHooks()](FunctionAndCla
713713
$output = $this->request('GET', 'products/shoes/show/123');
714714
~~~
715715

716-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Hook_test.php).
716+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Hook_test.php).
717717

718718
#### Controller with Name Collision
719719

@@ -739,7 +739,7 @@ class sub_Welcome_test extends TestCase
739739
}
740740
~~~
741741

742-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/sub/Welcome_test.php).
742+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/sub/Welcome_test.php).
743743

744744
### Mock Libraries
745745

@@ -875,15 +875,15 @@ A test case could be like this:
875875
}
876876
~~~
877877

878-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Exit_to_exception_test.php).
878+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Exit_to_exception_test.php).
879879

880880
#### Patching Functions
881881

882882
This patcher allows replacement of global functions that can't be mocked by PHPUnit.
883883

884884
But it has a few limitations. Some functions can't be replaced and it might cause errors.
885885

886-
So by default we can replace only a dozen pre-defined functions in [FunctionPatcher](https://github.com/kenjis/ci-phpunit-test/blob/v0.13.0/application/tests/_ci_phpunit_test/patcher/Patcher/FunctionPatcher.php#L27).
886+
So by default we can replace only a dozen pre-defined functions in [FunctionPatcher](https://github.com/kenjis/ci-phpunit-test/blob/v0.14.0/application/tests/_ci_phpunit_test/patcher/Patcher/FunctionPatcher.php#L27).
887887

888888
~~~php
889889
public function test_index()
@@ -896,7 +896,7 @@ So by default we can replace only a dozen pre-defined functions in [FunctionPatc
896896

897897
[MonkeyPatch::patchFunction()](FunctionAndClassReference.md#monkeypatchpatchfunctionfunction-return_value-class_method) replaces PHP native function `mt_rand()` in `Welcome::index` method, and it will return `100` in the test method.
898898

899-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Patching_on_function_test.php).
899+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Patching_on_function_test.php).
900900

901901
**Note:** If you call `MonkeyPatch::patchFunction()` without 3rd argument, all the functions (located in `include_paths` and not in `exclude_paths`) called in the test method will be replaced. So, for example, a function in CodeIgniter code might be replaced and it results in unexpected outcome.
902902

@@ -929,11 +929,11 @@ You could change return value of patched function using PHP closure:
929929
);
930930
~~~
931931

932-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Patching_on_function_test.php#L59-L80).
932+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Patching_on_function_test.php#L59-L80).
933933

934934
**Patch on Other Functions**
935935

936-
If you want to patch other functions, you can add them to [functions_to_patch](https://github.com/kenjis/ci-phpunit-test/blob/v0.13.0/application/tests/Bootstrap.php#L348) in `MonkeyPatchManager::init()`.
936+
If you want to patch other functions, you can add them to [functions_to_patch](https://github.com/kenjis/ci-phpunit-test/blob/v0.14.0/application/tests/Bootstrap.php#L348) in `MonkeyPatchManager::init()`.
937937

938938
But there are a few known limitations:
939939

@@ -958,7 +958,7 @@ This patcher allows replacement of methods in user-defined classes.
958958

959959
[MonkeyPatch::patchMethod()](FunctionAndClassReference.md#monkeypatchpatchmethodclassname-params) replaces `get_category_list()` method in `Category_model`, and it will return `[(object) ['name' => 'Nothing']]` in the test method.
960960

961-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.13.0/application/tests/controllers/Patching_on_method_test.php).
961+
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.14.0/application/tests/controllers/Patching_on_method_test.php).
962962

963963
#### Patching Constants
964964

@@ -1015,7 +1015,7 @@ If you want to use the constant patcher, please add `ConstantPatcher` in the `pa
10151015

10161016
Want to see more tests?
10171017

1018-
* https://github.com/kenjis/ci-app-for-ci-phpunit-test/tree/v0.13.0/application/tests
1018+
* https://github.com/kenjis/ci-app-for-ci-phpunit-test/tree/v0.14.0/application/tests
10191019
* https://github.com/kenjis/codeigniter-tettei-apps/tree/develop/application/tests
10201020

10211021
### Third Party Libraries

0 commit comments

Comments
 (0)