Should unit testing be built into the framework or just create a new folder called tests and include all the necessary classes and unit test each of them?
You must create a separate folder for it. Destroying production code with tests is usually not a good idea for performance and debugging reasons.
So, to test the model, should some parts of the structure be included in unit tests?
Less is better. Unit tests should not have any dependencies. If class A depends on B , you must mock B to make sure that if B fails, it does not crash A
The main advantage of unit tests (when everything is done correctly) is that it makes it easy to identify the problem. If A fails due to its dependency B , you first look at A , then B Again, if B depends on C and C crashing, you will have to look for A , B , and then C This pretty much destroys one of the biggest benefits of unit testing. If all the tests are performed correctly, a failure in C will not crash anywhere except C , so you will have one class to look for the problem.
To really make your code a mistake, you can use unit tests in conjunction with PHP statements :
$return = $this->addOne($some_param); assert('$return == $some_param + 1');
By the way, there is no difference between unit testing MVC, unlike unit testing in general.
netcoder
source share