Updating test_suite header to improve readability of connection names.

Adding test for using CakeTestCase::testAction() with fixturize parameter.
Updating TestsAppPostsController and adding Post Model to test suite.
Refs #5620

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7760 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2008-10-17 16:39:39 +00:00
parent f554d321b2
commit f875c0098b
5 changed files with 79 additions and 3 deletions

View file

@ -290,6 +290,34 @@ class CakeTestCaseTest extends CakeTestCase {
));
$this->assertEqual(array_keys($result['data']), array('name', 'pork'));
$db =& ConnectionManager::getDataSource('test_suite');
$_backPrefix = $db->config['prefix'];
$db->config['prefix'] = 'cake_testaction_test_suite_';
$config = $db->config;
$config['prefix'] = 'cake_testcase_test_';
ConnectionManager::create('cake_test_case', $config);
$db =& ConnectionManager::getDataSource('cake_test_case');
$fixture =& new PostFixture($db);
$fixture->create($db);
$fixture->insert($db);
$result = $this->Case->testAction('/tests_apps_posts/fixtured', array(
'return' => 'vars',
'fixturize' => true,
'connection' => 'cake_test_case',
));
$this->assertTrue(isset($result['posts']));
$this->assertEqual(count($result['posts']), 3);
$fixture->drop($db);
$db =& ConnectionManager::getDataSource('test_suite');
$db->config['prefix'] = $_backPrefix;
$fixture->drop($db);
Configure::write('modelPaths', $_back['model']);
Configure::write('controllerPaths', $_back['controller']);
Configure::write('viewPaths', $_back['view']);

View file

@ -179,7 +179,7 @@ class CakeTestCase extends UnitTestCase {
$object =& ClassRegistry::init($name);
//switch back to specified datasource.
$object->setDataSource($params['connection']);
$db =& ConnectionManager::getDataSource($object->useDbConfig);
$db =& ConnectionManager::getDataSource($object->useDbConfig);
$db->cacheSources = false;
$models[$object->alias] = array(

View file

@ -50,6 +50,7 @@
ul.tests li.skipped {background: url(http://cakephp.org/img/test-skip-icon.png) top left no-repeat;}
ul.tests li div { margin: 5px 0 8px 0; }
ul.tests li div.msg { font-weight: bold; }
table caption { color:#fff;}
</style>
<link rel="stylesheet" type="text/css" href="<?php echo $baseUrl; ?>css/cake.generic.css" />
</head>

View file

@ -43,16 +43,30 @@ class TestsAppsPostsController extends AppController {
$this->set('posts', $this->Post->find('all'));
$this->render('index');
}
/**
* check url params
*
*/
function url_var() {
$this->set('params', $this->params);
$this->render('index');
}
/**
* post var testing
*
*/
function post_var() {
$this->set('data', $this->data);
$this->render('index');
}
/**
* Fixturized action for testAction()
*
*/
function fixtured() {
$this->set('posts', $this->Post->find('all'));
$this->render('index');
}
}
?>

View file

@ -0,0 +1,33 @@
<?php
/* SVN FILE: $Id$ */
/**
* Test App Comment Model
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2006-2008, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.
* @since CakePHP v 1.2.0.7726
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
class Post extends AppModel {
var $useTable = 'posts';
var $name = 'Post';
}
?>