Adding check for XDebug in CCM test, fixing database check in MySQL, adding test coverage for View, fixes #4619

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6797 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-05-11 15:48:45 +00:00
parent 751a1b7cf7
commit 925e022e4f
4 changed files with 29 additions and 4 deletions

View file

@ -550,10 +550,10 @@ class View extends Object {
* @return array An array containing the identity elements of an entity
*/
function entity() {
return Set::filter(array(
return array_values(Set::filter(array(
ife($this->association, $this->association, $this->model),
$this->modelId, $this->field, $this->fieldSuffix
));
)));
}
/**
* Allows a template or element to set a variable that will be available in

View file

@ -36,6 +36,16 @@ require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_reporter.php';
* @subpackage cake.tests.cases.libs
*/
class CodeCoverageManagerTest extends UnitTestCase {
/**
* Skip if XDebug not installed
*
* @access public
*/
function skip() {
$this->skipif (!extension_loaded('xdebug'), 'XDebug not installed');
}
function testNoTestCaseSupplied() {
if (!in_array(php_sapi_name(), array('cli', 'cgi-fcgi'))) {
CodeCoverageManager::start(substr(md5(microtime()), 0, 5), new CakeHtmlReporter());

View file

@ -114,8 +114,9 @@ class DboMysqlTest extends CakeTestCase {
* @access public
*/
function skip() {
$db = ConnectionManager::getDataSource('test_suite');
$this->skipif ($db->config['driver'] != 'mysql', 'MySQL connection not available');
$this->_initDb();
$db =& ConnectionManager::getDataSource('test_suite');
$this->skipif($db->config['driver'] != 'mysql', 'MySQL connection not available');
}
/**
* Sets up a Dbo class instance for testing

View file

@ -356,8 +356,22 @@ class ViewTest extends UnitTestCase {
$this->assertIdentical($View->getVars(), array('key1', 'key2'));
$this->assertIdentical($View->getVar('key1'), 'value1');
$this->assertNull($View->getVar('key3'));
$View->set(array('key3' => 'value3'));
$this->assertIdentical($View->getVar('key3'), 'value3');
}
function testEntityReference() {
$View = new TestView($this->PostsController);
$View->model = 'Post';
$View->field = 'title';
$this->assertEqual($View->entity(), array('Post', 'title'));
$View->association = 'Comment';
$View->field = 'user_id';
$this->assertEqual($View->entity(), array('Comment', 'user_id'));
}
function testBadExt() {
$this->PostsController->action = 'something';
$this->PostsController->ext = '.whatever';