Unit Testing Controller using fixture in test_suit config

2008-03-05 Thread Micro

Does anyone know how to test controller in CakePhp 1.2 using the
test_suit controller?  I am using the testAction function to test my
controller.  However, it goes to the non-test_suit database.  Any idea?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Resource Needed: Zend Debugger or Eclipse Debugger for CakePhp

2008-02-08 Thread Micro

I try to use the Zend and/or Eclipse PHP Debugger to debuge the
CakePhp.  I just don't know how to debug my controller files.  I
setup  a breakpoint in my controller.php.  Then, I run the debugger.
But, it just doesn't stop at the breakpoint that I want.  I am totally
a newbie.  I know you guys must have a way to set it up.  I wonder if
there is any magic setup that I need to do.
--~--~-~--~~~---~--~~
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: Custom Component and Redirect problem

2008-02-08 Thread Micro

Ok, I try to remove all the print out and stuff, but, i still get the
same error.


class TradesController extends AppController {

var $name = 'Trades';
var $components = array('Date');
var $helpers = array('Html', 'Form');

   function index() {

}

   function add() {
 $this-redirect(array('action'='index'));
  }

}

On Feb 7, 5:09 pm, Kjell Bublitz [EMAIL PROTECTED] wrote:
 If you just wanna test if the timestamp is there, you can simply exit
 before doing the redirect().

 You could just do this: pr($timeStamp); exit(); if you expect an array.. if
 you expect just a string exit($timeStamp); will do the same trick.. as an
 alternative to pr() which is just the print_r() output with a pre tag
 around it, you can use var_dump($timeStamp); to get more details.

 If you are happy with the results, remove the exit() and continue..

 Another way is to take a decent remote debugger with an IDE that uses it.
 That way you can save yourself from doing all that print_r and echo stuff..

 Good IDEs are Zend Studio and Komodo Pro.

 HTH,
 Kjell

 On Feb 7, 2008 11:43 PM, Micro [EMAIL PROTECTED] wrote:



  I am using CakePhp 1.2 So, I created a component called Date.  I
  embedded in my class following the example.

  My controller class:

  class TradesController extends AppController {

 var $name = 'Trades';
 var $components = array('Date');
 var $helpers = array('Html', 'Form');

function index() {

 }

function add() {
 $timeStamp = $this-Date-getTimestamp();
  print_r($timeStamp);
 $this-redirect(array('action'='index'));
   }

  }

  I get this error

  Warning (2): Cannot modify header information - headers already sent
  by (output started at C:\xampplite\htdocs\cake12\app\controllers
  \components\date.php:119) [CORE\cake\libs\controller\controller.php,
  line 546]

  If I uncomment the  $this-redirect(array('action'='index')), my
  component works perfectly fine, and i don't get any error.  I try to
  comment out the component part, and it works fine.  The problem only
  occurs when I use my custom component and has the redirect line.  Any
  clue?  Thank you.
--~--~-~--~~~---~--~~
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: Custom Component and Redirect problem

2008-02-08 Thread Micro

I figure out now.  There is some funny character in my Date
component.  That's why it screw up the header for redirect.  Thank you
for everyone input.  I love the CakePhp community.

On Feb 8, 11:26 am, Micro [EMAIL PROTECTED] wrote:
 Ok, I try to remove all the print out and stuff, but, i still get the
 same error.

 class TradesController extends AppController {

 var $name = 'Trades';
 var $components = array('Date');
 var $helpers = array('Html', 'Form');

function index() {

 }

function add() {
  $this-redirect(array('action'='index'));
   }

 }

 On Feb 7, 5:09 pm, Kjell Bublitz [EMAIL PROTECTED] wrote:

  If you just wanna test if the timestamp is there, you can simply exit
  before doing the redirect().

  You could just do this: pr($timeStamp); exit(); if you expect an array.. if
  you expect just a string exit($timeStamp); will do the same trick.. as an
  alternative to pr() which is just the print_r() output with a pre tag
  around it, you can use var_dump($timeStamp); to get more details.

  If you are happy with the results, remove the exit() and continue..

  Another way is to take a decent remote debugger with an IDE that uses it.
  That way you can save yourself from doing all that print_r and echo stuff..

  Good IDEs are Zend Studio and Komodo Pro.

  HTH,
  Kjell

  On Feb 7, 2008 11:43 PM, Micro [EMAIL PROTECTED] wrote:

   I am using CakePhp 1.2 So, I created a component called Date.  I
   embedded in my class following the example.

   My controller class:

   class TradesController extends AppController {

  var $name = 'Trades';
  var $components = array('Date');
  var $helpers = array('Html', 'Form');

 function index() {

  }

 function add() {
  $timeStamp = $this-Date-getTimestamp();
   print_r($timeStamp);
  $this-redirect(array('action'='index'));
}

   }

   I get this error

   Warning (2): Cannot modify header information - headers already sent
   by (output started at C:\xampplite\htdocs\cake12\app\controllers
   \components\date.php:119) [CORE\cake\libs\controller\controller.php,
   line 546]

   If I uncomment the  $this-redirect(array('action'='index')), my
   component works perfectly fine, and i don't get any error.  I try to
   comment out the component part, and it works fine.  The problem only
   occurs when I use my custom component and has the redirect line.  Any
   clue?  Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Custom Component and Redirect problem

2008-02-07 Thread Micro

I am using CakePhp 1.2 So, I created a component called Date.  I
embedded in my class following the example.

My controller class:

class TradesController extends AppController {

var $name = 'Trades';
var $components = array('Date');
var $helpers = array('Html', 'Form');

   function index() {

}

   function add() {
$timeStamp = $this-Date-getTimestamp();
 print_r($timeStamp);
$this-redirect(array('action'='index'));
  }

}

I get this error

Warning (2): Cannot modify header information - headers already sent
by (output started at C:\xampplite\htdocs\cake12\app\controllers
\components\date.php:119) [CORE\cake\libs\controller\controller.php,
line 546]


If I uncomment the  $this-redirect(array('action'='index')), my
component works perfectly fine, and i don't get any error.  I try to
comment out the component part, and it works fine.  The problem only
occurs when I use my custom component and has the redirect line.  Any
clue?  Thank you.
--~--~-~--~~~---~--~~
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: Problem with import in test fixtures?

2008-02-01 Thread Micro

Hey, i got the same problem too.  I am still not able to import my
fixtures.
My cakephp version is: 1.2.0.6311 beta, and my simpletest version is :
1.0.1beta2

This is my model:

?php
class Stock extends AppModel {

var $name = 'Stock';
var $useTable = 'stocks';
var $primaryKey = 'SYMBOL';
var $validate = array(
);
?

?php

App::import('Model', 'Stock');

class StockTest extends Stock{
var $name = 'StockTest';
var $useDbConfig = 'test_suite';
var $cacheSources = false;

  //   var $useTable = null;
  //  var $tablePrefix = null;
}

class StockTestCase extends CakeTestCase {

var $fixtures = array('stock_test');


function testCreateRecords() {

$this-TestObject = new StockTest();
$result = $this-TestObject-findCount();
$expected = count($this-records);
$this-assertEqual($result, $expected);

   }

}
?

My fixture:
?php

class StockTestFixture extends CakeTestFixture {

var $name = 'StockTest';
var $import = 'Stock';

var $records = array(
...

);

}
?

The error that i got is:

Error:  Database table test_suite_stocks for model Stock was not
found.

I just don't get it.  I can make my unit testing working without the
fixture. But, it will go to my real table instead of the test suit
table.  Please help.  I have been trying to do this for couple days
now.



On Jan 8, 4:35 pm, Robby Anderson [EMAIL PROTECTED] wrote:
 Woo hoo! Got it to work. For anyone interested, I believe it had to do
 with the customtablein my Model declaration (var $useTable).

 To solve my issue, I added two lines to my Test Model declaration:

 class UserTest extends User {

 var $name = 'UserTest';
 var $useDbConfig = 'test_suite';
 var $cacheSources = false;

 var $useTable = null;
 var $tablePrefix = null;

 }

 The last two lines - setting useTable and tablePrefix to null - solved
 my issue, and now my test structure/data is importing perfectly! Me
 = :)

 On Jan 8, 3:55 pm, Gwoo [EMAIL PROTECTED] wrote:

  Robby,
  Come to IRC, its much more fun than having to send 4 messages in 2hrs
  with no response.
  #cakephp, irc.freenode.net

 Th   anks, Gwoo - I'll do that.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---