Re: Unit testing in 1.2

2007-12-14 Thread Gwoo

What revision do you have? The fix should be in anything after pre
beta.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



RE: Unit Testing in 1.2

2007-03-18 Thread Mariano Iglesias

You can simplify the test a lot, just put it like (see the use of
loadController() instead of all the junk I've just given you):

uses('controller' . DS . 'controller');

loadController('Users');

class UsersControllerTest extends UnitTestCase {
function testGetTitle() {
$controller =& new UsersController();

$result = $controller->_getTitle();
$expected = 'Page Title';

$this->assertEqual($result, $expected);
}

}

-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


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



RE: Unit Testing in 1.2

2007-03-18 Thread Mariano Iglesias

1. Unzip simpletest at cake/vendors/simpletest (inside after installing you
should see simple test files like unit_tester.php)

2. Set up your tests on app/tests inside the appropriate directory. As a
guidance, you can set up your controller tests under
app/tests/cases/controllers/. For example, let's assume you have a
controller called Users like so:

class UsersController extends AppController {
var $name = 'Users';
var $uses = null;

function index() {
$this->set('title', $this->_getTitle());
}

function _getTitle() {
return 'Page Title';
}
}

And you want to test the method _getTitle() (I know, how lame is that) then
set up a users_controller.test.php on app/tests/cases/controllers/ with the
following:

uses('controller' . DS . 'controller');

if (file_exists(APP . 'app_controller.php')) {
require_once (APP . 'app_controller.php');
} else {
class AppController extends Controller {
}
}

require_once(APP . 'controllers' . DS . 'users_controller.php');

class UsersControllerTest extends UnitTestCase {
function testGetTitle() {
$controller =& new UsersController();

$result = $controller->_getTitle();
$expected = 'Page Title';

$this->assertEqual($result, $expected);
}

}

3. Assuming your Cake application is hosted at http://localhost/cake, go to:

http://localhost/cake/test.php

   And click on "App Test Cases". You'll see a test listed there called
controllers/users_controller.test.php.

   Click on it and you'll see your test succeed :)

That's it in a nutshell, basically. If you checkout Cake 1.2 SVN you can see
we've started building some tests in Cake's core and you can certainly learn
from them.


-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: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
de Dat Chu
Enviado el: Domingo, 18 de Marzo de 2007 02:59 p.m.
Para: Cake PHP
Asunto: Unit Testing in 1.2

Does anyone know how to go about running a unit test case / suite in
1.2 . I can't seem to find the documentation anywhere about this.

I have version 1.2 of cake now and have put some test code under /app/
tests/cases/controllers/my_controller.test.php


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Unit Testing in 1.2

2007-03-18 Thread Walker Hamilton

Maybe try DH's testing suite for Cake 1.2 ?

http://cakebaker.42dh.com/2006/12/18/testing-with-cakephp-12-a-preview/

he's got instructions.

On Mar 18, 12:58 pm, "Dat Chu" <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> Does anyone know how to go about running a unit test case / suite in
> 1.2 . I can't seem to find the documentation anywhere about this.
>
> I have version 1.2 of cake now and have put some test code under /app/
> tests/cases/controllers/my_controller.test.php
>
> How do I run it? Do I need to put SimpleTest lib somewhere?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---