Comments (10)
If we do unit tests, we should test only a hook class.
This is my test case: https://github.com/kenjis/codeigniter-tettei-apps/blob/develop/application/tests/hooks/Convert_encoding_test.php#L13-27
The hook converts character encoding of $_POST
on some conditions at pre_system
.
Do you want to do functional tests including hooks? If so, we have to implement something to support it.
Anyway, first of all, what do you want to test?
from ci-phpunit-test.
I have one library for check it is authorized call method, and this call in post_controller_constructor.
from ci-phpunit-test.
If I were you, I write tests only for the library, and write controller tests (hook is just ignored). I think it is enough.
But do you want controller tests to call the hook?
from ci-phpunit-test.
I want to be sure that the hook is working.
But I'm going to follow your suggestion that also works.
from ci-phpunit-test.
I want to be sure that the hook is working.
If your config for hooks is right, it must be working. It is CodeIgniter's specification.
We don't have to test if we trust CodeIgniter.
And I also test my application with Selenium for acceptance test. It probably test hooks are working or not.
I'm not sure we need support testing with hooks. I ignored hooks, because
- It is not needed for unit testing
- too many hook points, so I was not sure how to implement
But if you really want to do it, you can add code to call hooks to request()
method.
from ci-phpunit-test.
See #23
from ci-phpunit-test.
Improved now with #23
from ci-phpunit-test.
I found a hack to add autoloader for controllers in pre_system
hook.
3 . Using an autoload function with hooks (the slow and right way)
http://avenir.ro/codeigniter-tutorials/no-more-my_controller-how-you-can-create-more-than-one-base-controller/
In this case, we need to call pre_system
before executing controllers.
pre_system
is called in PHPUnit bootstrap (called in core/CodeIgniter.php
in CIPHPUnitTest::init()
).
So there is no problem.
from ci-phpunit-test.
I added docs on hooks in current ci-phpunit-test:
https://github.com/kenjis/ci-phpunit-test/blob/master/docs/HowToWriteTests.md#hooks
from ci-phpunit-test.
I think the current specification is good enough. So I'm planning to close the issue.
If anyone has any opinion about it, please post.
from ci-phpunit-test.
Related Issues (20)
- 3.0.2 release date? HOT 2
- Coverage report is acting weird HOT 2
- Cannot create mock whose methods throw exceptions HOT 2
- How to extend the test runner for post operations? HOT 4
- 3.x new version with Updates for PHP 8.1 HOT 3
- How to stop PHP code execution when exit() in unit test? HOT 5
- Argument 1 passed to PHPUnit\Runner\TestSuiteSorter::reorderTestsInSuite() must implement interface PHPUnit\Framework\Test, instance of PHPUnit\Framework\TestSuite given HOT 3
- PHPUnit 9.5.24 + CodeIgniter 3.1.13 + PHP 8.1 HOT 2
- Session problem HOT 8
- Mocking DB object can't use getDouble? HOT 1
- How to clear RAM memory after run testcase in testsuite? HOT 3
- How to mock DB in CI? HOT 1
- PHP Fatal error: Uncaught Error: Class "TestCase" not found HOT 2
- Replacement of helper function redirect() does not work HOT 3
- cant set session $this->session->userdata HOT 1
- Upgrading to CodeIgniter4 is strongly recommended
- How to test external API with json response? HOT 1
- 1.0.2 fails with phpunit <7 when installed with "--from-composer" HOT 2
- issue during code coverage when referencing $this->uri in a view HOT 5
- Add support for php 8.2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ci-phpunit-test.