Re: Tests - Fixture does not truncate tables

2012-05-24 Thread jeremyharris
I did some research and yes, I believe it is a bug. The problem is that 
when it tries to create the table and mark it as being created, it will 
fail because the table already exists and then skips marking it as created, 
which is what's needed in order for truncate to happen.

I'll add it on Lighthouse with the details. Thanks!

On Wednesday, May 23, 2012 2:08:21 AM UTC-7, Pierre Boutet wrote:

 Hi, 

 I am using Cake Tests, on cake 2.1.1 (upgraded from cake 1.3) and I 
 have a problem : when running tests, tables are not truncated after 
 each test. 

 I use the params $dropTables = false; because I don't want create 
 tables before each test, only fill them and truncate after tests. 

 I don't find how to force truncate in my app, but I do it by modifying 
 CakePhp code, in file Cate/TestSuite/Fixture/CakeFixtureManager.php : 
 I modify function unload() like this : (added lines are the ones 
 begining by # ) 
 public function unload(CakeTestCase $test) { 
 $fixtures = !empty($test-fixtures) ? $test-fixtures : 
 array(); 
 foreach (array_reverse($fixtures) as $f) { 
 if (isset($this-_loaded[$f])) { 
 $fixture = $this-_loaded[$f]; 

 if (!empty($fixture-created)) { 
 foreach ($fixture-created as $ds) 
 { 
 $db = 
 ConnectionManager::getDataSource($ds); 
 
 debug($fixture-truncate($db)); 

 } 
 } 
 # else { 
 # $db = ConnectionManager::getDataSource($fixture-useDbConfig); 
 # $fixture-truncate($db); 
 # } 
 } 
 } 
 } 

 Is it a bug in Cake lib or did I miss something ?

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


Re: Tests - Fixture does not truncate tables

2012-05-24 Thread jeremyharris
Actually it appears you already reported it :) I'll comment there.

On Thursday, May 24, 2012 7:17:12 AM UTC-7, jeremyharris wrote:

 I did some research and yes, I believe it is a bug. The problem is that 
 when it tries to create the table and mark it as being created, it will 
 fail because the table already exists and then skips marking it as created, 
 which is what's needed in order for truncate to happen.

 I'll add it on Lighthouse with the details. Thanks!

 On Wednesday, May 23, 2012 2:08:21 AM UTC-7, Pierre Boutet wrote:

 Hi, 

 I am using Cake Tests, on cake 2.1.1 (upgraded from cake 1.3) and I 
 have a problem : when running tests, tables are not truncated after 
 each test. 

 I use the params $dropTables = false; because I don't want create 
 tables before each test, only fill them and truncate after tests. 

 I don't find how to force truncate in my app, but I do it by modifying 
 CakePhp code, in file Cate/TestSuite/Fixture/CakeFixtureManager.php : 
 I modify function unload() like this : (added lines are the ones 
 begining by # ) 
 public function unload(CakeTestCase $test) { 
 $fixtures = !empty($test-fixtures) ? $test-fixtures : 
 array(); 
 foreach (array_reverse($fixtures) as $f) { 
 if (isset($this-_loaded[$f])) { 
 $fixture = $this-_loaded[$f]; 

 if (!empty($fixture-created)) { 
 foreach ($fixture-created as 
 $ds) { 
 $db = 
 ConnectionManager::getDataSource($ds); 
 
 debug($fixture-truncate($db)); 

 } 
 } 
 # else { 
 # $db = ConnectionManager::getDataSource($fixture-useDbConfig); 
 # $fixture-truncate($db); 
 # } 
 } 
 } 
 } 

 Is it a bug in Cake lib or did I miss something ?



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