Skip to content

Commit 5536b66

Browse files
committed
Update docs for release
1 parent dc332d4 commit 5536b66

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

docs/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.13.0 (Not Released)
3+
## v0.13.0 (2016/11/20)
44

55
### Added
66

docs/HowToWriteTests.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# ci-phpunit-test for CodeIgniter 3.0
22

3-
version: **v0.12.2** |
3+
version: **v0.13.0** |
4+
[v0.12.2](https://github.com/kenjis/ci-phpunit-test/blob/v0.12.2/docs/HowToWriteTests.md) |
45
[v0.11.3](https://github.com/kenjis/ci-phpunit-test/blob/v0.11.3/docs/HowToWriteTests.md) |
56
[v0.10.1](https://github.com/kenjis/ci-phpunit-test/blob/v0.10.1/docs/HowToWriteTests.md) |
67
[v0.9.1](https://github.com/kenjis/ci-phpunit-test/blob/v0.9.1/docs/HowToWriteTests.md) |
@@ -255,7 +256,7 @@ class Inventory_model_test extends TestCase
255256
}
256257
~~~
257258

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

260261
#### Database Seeding
261262

@@ -276,7 +277,7 @@ You can use them like below:
276277
}
277278
~~~
278279

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

281282
#### Using PHPUnit Mock Objects
282283

@@ -341,7 +342,7 @@ If you don't know well about PHPUnit Mock Objects, see [Test Doubles](https://ph
341342
}
342343
~~~
343344

344-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.12.2/application/tests/models/Category_model_mocking_db_test.php).
345+
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).
345346

346347
### Libraries
347348

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

384385
**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.
385386

386-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.12.2/application/tests/controllers/sub/Sub_test.php).
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).
387388

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

@@ -403,7 +404,7 @@ class Welcome_test extends TestCase
403404

404405
**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.
405406

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

408409
#### REST Request
409410

@@ -441,7 +442,7 @@ You can set request header with [$this->request->setHeader()](FunctionAndClassRe
441442
}
442443
~~~
443444

444-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.12.2/application/tests/controllers/api/Example_test.php).
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).
445446

446447
#### Ajax Request
447448

@@ -456,7 +457,7 @@ You can use [$this->ajaxRequest()](FunctionAndClassReference.md#testcaseajaxrequ
456457
}
457458
~~~
458459

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

461462
#### Request and Use Mocks
462463

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

487488
**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.
488489

489-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.12.2/application/tests/controllers/Mock_phpunit_test.php).
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).
490491

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

@@ -536,7 +537,7 @@ In this case, You can use [$this->request->setCallablePreConstructor()](Function
536537
}
537538
~~~
538539

539-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.12.2/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.13.0/application/tests/controllers/Auth_check_in_construct_test.php).
540541

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

@@ -600,7 +601,7 @@ I recommend using PHPUnit mock objects. [$this->getDouble()](FunctionAndClassRef
600601
}
601602
~~~
602603

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

605606
#### `redirect()`
606607

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

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

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

625626
##### Upgrade Note for v0.4.0
626627

@@ -662,7 +663,7 @@ You can use [$this->assertResponseCode()](FunctionAndClassReference.md#testcasea
662663
}
663664
~~~
664665

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

667668
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.
668669

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

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

717718
#### Controller with Name Collision
718719

@@ -738,7 +739,7 @@ class sub_Welcome_test extends TestCase
738739
}
739740
~~~
740741

741-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.12.2/application/tests/controllers/sub/Welcome_test.php).
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).
742743

743744
### Mock Libraries
744745

@@ -876,15 +877,15 @@ A test case could be like this:
876877
}
877878
~~~
878879

879-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.12.2/application/tests/controllers/Exit_to_exception_test.php).
880+
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).
880881

881882
#### Patching Functions
882883

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

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

887-
So by default we can replace only a dozen pre-defined functions in [FunctionPatcher](https://github.com/kenjis/ci-phpunit-test/blob/v0.12.2/application/tests/_ci_phpunit_test/patcher/Patcher/FunctionPatcher.php#L27).
888+
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).
888889

889890
~~~php
890891
public function test_index()
@@ -897,7 +898,7 @@ So by default we can replace only a dozen pre-defined functions in [FunctionPatc
897898

898899
[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.
899900

900-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.12.2/application/tests/controllers/Patching_on_function_test.php).
901+
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).
901902

902903
**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.
903904

@@ -930,11 +931,11 @@ You could change return value of patched function using PHP closure:
930931
);
931932
~~~
932933

933-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.12.2/application/tests/controllers/Patching_on_function_test.php#L59-L80).
934+
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).
934935

935936
**Patch on Other Functions**
936937

937-
If you want to patch other functions, you can add them to [functions_to_patch](https://github.com/kenjis/ci-phpunit-test/blob/v0.12.2/application/tests/Bootstrap.php#L348) in `MonkeyPatchManager::init()`.
938+
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()`.
938939

939940
But there are a few known limitations:
940941

@@ -959,7 +960,7 @@ This patcher allows replacement of methods in user-defined classes.
959960

960961
[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.
961962

962-
See [working sample](https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/v0.12.2/application/tests/controllers/Patching_on_method_test.php).
963+
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).
963964

964965
#### Patching Constants
965966

@@ -1016,7 +1017,7 @@ If you want to use the constant patcher, please add `ConstantPatcher` in the `pa
10161017

10171018
Want to see more tests?
10181019

1019-
* https://github.com/kenjis/ci-app-for-ci-phpunit-test/tree/v0.12.2/application/tests
1020+
* https://github.com/kenjis/ci-app-for-ci-phpunit-test/tree/v0.13.0/application/tests
10201021
* https://github.com/kenjis/codeigniter-tettei-apps/tree/develop/application/tests
10211022

10221023
### Third Party Libraries

0 commit comments

Comments
 (0)