I am trying to test a controller function ... I want to test some things: a) It throws an invalid request exception when a specific logic is used. B) It works correctly when the right logic is correct.
I have written a few unit tests and they all seem cool, only one can get me the documentation, but the integration test is interesting and potentially useful, I do not think I should join it Imagine applying it without (which I do not want to necessarily).
Namespace App \ Test \ Testicles \ Controller; Use cake \ ORM \ TableRegistry; Use cake \ TestSuite \ IntegrationTestCase; The class is expanded into Muster Controllant Accountant Season {Public Function Testin ()) ($ -> (-); $ This-> Set Estimated Exception ('Invalid Request');}
< P>} Indicators appreciated.
integration seasons
class, as its name implies, for integration testing. That is, it will test the interaction between the controller and any other class who uses the feedback.
There is another way of testing controller, which is more difficult to complete, but allows you to test the controlling methods in isolation:
public function testMyControllerMethod () {$ Request = $ this- & gt; GetMock ('cake \ network \ request'); $ Response = $ this- & gt; GetMock ('cake \ network \ response'); $ Controller = new MyController ($ request, $ response); $ Controller- & gt; StartupProcess (); // Add some logic and expectations here. For example, you have $ controller-gt; Call the name of the tag in a counterfeit class / $ method that you would get $ controller- & gt; Want to test myMethod ('param1', 'param2'); }
No comments:
Post a Comment