CakePHP 2.0 - Testing InnoDB transactions while using schema importing - is this possible?

2011-11-27 Thread Thiago Campezzi
Hey everyone,

I'm trying to run some model tests using MySQL transactions. My model
uses an InnoDB table, so transactions are supported and do work in the
default database configuration. However, if I use the "schema
importing" feature for my test fixtures (very practical as schemas
change a lot during development), the table generated by the test
suite uses the "MEMORY" engine, which doesn't support transactions.
And obviously my tests fail.

If I disable schema importing by redefining all my fields in the
fixture specifying the "tableParameters" key, it does use InnoDB and
transactions do work as expected.

Is there a way to use schema importing but still specifying the InnoDB
engine?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


2.0 "Testing Controllers" documentation suggestion/correction

2011-10-28 Thread Thiago Campezzi
Hi everyone,

I was taking a look at the documentation for the test suite in CakePHP
2.0 - more specifically the part about testing controller code:

http://book.cakephp.org/2.0/en/development/testing.html#testing-controllers

The code example provided in this heading doesn't include the "public
$fixtures" line - if you just copy and paste that example, it will run
using the default database connection instead of the test one. This
might have been omitted to make the example simpler, but I think the
consequences of forgetting this line are potentially very dangerous
(you might delete or update live data accidentally!).

Here's a version of the same example that uses test fixtures, thus
causing the test suite to use the test database connection:

class ArticlesControllerTest extends ControllerTestCase {

public $fixtures = array('app.article');

function testIndex() {
$result = $this->testAction('/articles/index');
debug($result);
}

... and so on until the end of the class

I hope this saves someone some trouble when running and debugging
their tests :)

Cheers,
Thiago

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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