Re: Unitesting with Simpletest
Now i can solve all of my above problems using webtestcase class. I can dump the result of the call by using showSource() method. However, I don't know how to get these result to be edited. For example, my call will show {code:200} if I use $this- showSource(). However, i still want to pass the result into one variable (var) and want to get only 200 for further computation. Can you give me any idea for it? I am pretty sure there is some functions to do it. However, it is my bad that cannot find it. Thank very much in advance. Regards, Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Unitesting with Simpletest
Thank for your advice and suggestions. On May 22, 1:40 am, LunarDraco mdc...@gmail.com wrote: Exactly what are you trying to test? It looks like your trying to test the http POST and response protocols, I'm pretty sure Apache and other web server engines have fully tested those. First make sure your logic is as deep into the model as possible. As models are much easier to test than controllers. The rest of this sounds like your testing the controller. The controller is not exactly simple to test against however it can be done. And you may need to use a few different MOCK objects to get the results your looking for. Mark Story has a couple of articles on how to test the controllers. There is a bit of setup involved and you may have to create some mock objects to accomplish the test. http://mark-story.com/posts/view/testing-cakephp-controllers-the-hard...http://mark-story.com/posts/view/testing-cakephp-controllers-mock-obj... On May 20, 9:17 am, Aung thein.aungmy...@gmail.com wrote: Hi team, I have been using cakephp for one of my projects and we are trying to test with Simpletest as provided in the documentation. However, our api cannot be called directly. We have to use * Method: POST * Header Name: Content-Type * Header Value: application/x-www-form-urlencoded * Body: params={username:aung,password:pass} I can solve the first problem by using 'method'=post in testAction() method from CakeTestCase as inhttp://book.cakephp.org/view/366/Testing-controllers page. However, i don't have any idea how to set the header name, type and params into the body. We can use httpclient to do these things but httpclient is a bit manual and we think simpletest in cakephp framework is better if we can solve this problem. If anyone knows, please let me know the solution :) .. Thank very much in advance. Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Unitesting with Simpletest
Exactly what are you trying to test? It looks like your trying to test the http POST and response protocols, I'm pretty sure Apache and other web server engines have fully tested those. First make sure your logic is as deep into the model as possible. As models are much easier to test than controllers. The rest of this sounds like your testing the controller. The controller is not exactly simple to test against however it can be done. And you may need to use a few different MOCK objects to get the results your looking for. Mark Story has a couple of articles on how to test the controllers. There is a bit of setup involved and you may have to create some mock objects to accomplish the test. http://mark-story.com/posts/view/testing-cakephp-controllers-the-hard-way http://mark-story.com/posts/view/testing-cakephp-controllers-mock-objects-edition On May 20, 9:17 am, Aung thein.aungmy...@gmail.com wrote: Hi team, I have been using cakephp for one of my projects and we are trying to test with Simpletest as provided in the documentation. However, our api cannot be called directly. We have to use * Method: POST * Header Name: Content-Type * Header Value: application/x-www-form-urlencoded * Body: params={username:aung,password:pass} I can solve the first problem by using 'method'=post in testAction() method from CakeTestCase as inhttp://book.cakephp.org/view/366/Testing-controllers page. However, i don't have any idea how to set the header name, type and params into the body. We can use httpclient to do these things but httpclient is a bit manual and we think simpletest in cakephp framework is better if we can solve this problem. If anyone knows, please let me know the solution :) .. Thank very much in advance. Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Unitesting with Simpletest
Hi team, I have been using cakephp for one of my projects and we are trying to test with Simpletest as provided in the documentation. However, our api cannot be called directly. We have to use * Method: POST * Header Name: Content-Type * Header Value: application/x-www-form-urlencoded * Body: params={username:aung,password:pass} I can solve the first problem by using 'method'=post in testAction() method from CakeTestCase as in http://book.cakephp.org/view/366/Testing-controllers page. However, i don't have any idea how to set the header name, type and params into the body. We can use httpclient to do these things but httpclient is a bit manual and we think simpletest in cakephp framework is better if we can solve this problem. If anyone knows, please let me know the solution :) .. Thank very much in advance. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en