Also look into the code for CakeTestCase (cake/tests/lib/cake_test_case.php)
and something will definitely drive your attention: a method called
testAction().
I still need to write an article about this but basically make your test
case extend CakeTestCase, and then you can do:
$result = $this->testAction('/posts/index');
$result will contain whatever posts/index view renders. If you want instead
to get whatever the action index() returns (via a return statement), then:
$result = $this->testAction('/posts/index', array('return' => 'result'));
-MI
---------------------------------------------------------------------------
Remember, smart coders answer ten questions for every question they ask.
So be smart, be cool, and share your knowledge.
BAKE ON!
blog: http://www.MarianoIglesias.com.ar
-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de FallenJehova
Enviado el: Domingo, 23 de Septiembre de 2007 10:46 a.m.
Para: Cake PHP
Asunto: Re: Testing Controllers in 1.2
I'm sure it's late, but just in case anybody google this.
When using the loadController(), just pass the Conroller name without
'Controller''. Cake will concatenate it later.
in your example:
loadController ('Posts');
On 7 sep, 18:38, dresdn <[EMAIL PROTECTED]> wrote:
> Hi.
>
> I just started looking at CakePHP just over a week ago, and so far, I
> like what I see. Based on documentation, etc., I've decided to start
> out with the 1.2 branch due to all the nice new features.
>
> One of the things I was most interested in was testing, and using the
> Blog Tutorial as a starting point, I wanted to write some tests. I
> did
findhttp://bakery.cakephp.org/articles/view/testing-models-with-cakephp-1...
> , but for some reason I'm not able to do the same for the controller.
>
> What I have so far in tests/cases/controller/post_controller.test.php
> is:
>
> <?php
> loadController ('PostsController');
>
> class PostsTest extends PostsController {
> var $name = 'PostsTest';
>
> }
>
> class PostsControllerTest extends CakeTestCase {
> var $fixtures = array ('post_test');
>
> function testIndex () {
> $this->get ('/posts');
> $this->assertResponse (SUCCESS);
> }
>
> }
>
> When I run the test, I get a Fatal error: Class 'PostsController' not
> found in
>
> It looks like loadController() isn't doing anything. Am I way off on
> this? I'm running from svn rev. 5619.
>
> Any help would be appreciated!
>
> Thanks in advance,
> Mike
__________ Información de NOD32, revisión 2545 (20070923) __________
Este mensaje ha sido analizado con NOD32 antivirus system
http://www.nod32.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---