Adding tests and fixtures for self-join associations, and fixing JS syntax for 'indicator' (Ticket #2302)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4705 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-03-29 02:16:00 +00:00
parent 0c2b92a650
commit 381ec92b4c
4 changed files with 94 additions and 1 deletions

View file

@ -658,11 +658,17 @@ class AjaxHelper extends AppHelper {
if (isset($options['indicator'])) {
if (isset($options['loading'])) {
if (!empty($options['loading']) && substr(trim($options['loading']), -1, 1) != ';') {
$options['loading'] .= '; ';
}
$options['loading'] .= "Element.show('{$options['indicator']}');";
} else {
$options['loading'] = "Element.show('{$options['indicator']}');";
}
if (isset($options['complete'])) {
if (!empty($options['complete']) && substr(trim($options['complete']), -1, 1) != ';') {
$options['complete'] .= '; ';
}
$options['complete'] .= "Element.hide('{$options['indicator']}');";
} else {
$options['complete'] = "Element.hide('{$options['indicator']}');";

View file

@ -128,6 +128,21 @@
class Category extends CakeTestModel {
var $name = 'Category';
}
/**
* Short description for class.
*
* @package cake.tests
* @subpackage cake.tests.cases.libs.model
*/
class CategoryThread extends CakeTestModel {
var $name = 'CategoryThread';
var $belongsTo = array(
'ParentCategory' => array(
'className' => 'CategoryThread',
'foreignKey' => 'parent_id'
)
);
}
/**
* Short description for class.
*
@ -135,7 +150,7 @@
* @subpackage cake.tests.cases.libs.model
*/
class ModelTest extends CakeTestCase {
var $fixtures = array( 'core.category', 'core.user', 'core.article', 'core.tag', 'core.articles_tag', 'core.comment', 'core.attachment' );
var $fixtures = array( 'core.category', 'core.category_thread', 'core.user', 'core.article', 'core.tag', 'core.articles_tag', 'core.comment', 'core.attachment' );
function start() {
parent::start();
@ -171,6 +186,17 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
function testFindAllFakeThread() {
$this->model =& new CategoryThread();
$this->db->fullDebug = true;
$this->model->recursive = 10;
$this->model->id = 1;
$data = $this->model->read();
pr($data);
}
function testFindAll() {
$this->model =& new User();

View file

@ -125,6 +125,12 @@ class AjaxTest extends UnitTestCase {
$this->assertEqual($result, $expected);
}
function testSubmitWithIndicator() {
$result = $this->Ajax->submit('Add', array('div' => false, 'url' => "/controller/action", 'indicator' => 'loading', 'loading' => "doSomething()", 'complete' => 'doSomethingElse() '));
$this->assertPattern('/onLoading:function\(request\){doSomething\(\);\s+Element.show\(\'loading\'\);}/', $result);
$this->assertPattern('/onComplete:function\(request, json\){doSomethingElse\(\) ;\s+Element.hide\(\'loading\'\);}/', $result);
}
function tearDown() {
unset($this->Ajax);
}

View file

@ -0,0 +1,55 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* Copyright 2005-2007, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @subpackage cake.tests.fixtures
* @since CakePHP(tm) v 1.2.0.4667
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
/**
* Short description for class.
*
* @package cake.tests
* @subpackage cake.tests.fixtures
*/
class CategoryThreadFixture extends CakeTestFixture {
var $name = 'CategoryThread';
var $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'parent_id' => array('type' => 'integer', 'null' => false),
'name' => array('type' => 'string', 'null' => false),
'created' => 'datetime',
'updated' => 'datetime'
);
var $records = array(
array('id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 4, 'parent_id' => 2, 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 5, 'parent_id' => 3, 'name' => 'Category 1.1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 6, 'parent_id' => 0, 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 7, 'parent_id' => 6, 'name' => 'Category 2.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31')
);
}
?>