Fix coding standards in Case/Model/Behavior.

This commit is contained in:
mark_story 2012-03-18 14:31:13 -04:00
parent 346e048371
commit fc234d82f1
7 changed files with 68 additions and 67 deletions

View file

@ -98,6 +98,7 @@ class AclPerson extends CakeTestModel {
return array('AclPerson' => array('id' => $motherId)); return array('AclPerson' => array('id' => $motherId));
} }
} }
} }
/** /**
@ -135,6 +136,7 @@ class AclUser extends CakeTestModel {
public function parentNode() { public function parentNode() {
return null; return null;
} }
} }
/** /**
@ -172,6 +174,7 @@ class AclPost extends CakeTestModel {
public function parentNode() { public function parentNode() {
return null; return null;
} }
} }
/** /**
@ -342,7 +345,7 @@ class AclBehaviorTest extends CakeTestCase {
$this->assertEquals($result['Aro']['parent_id'], 7); $this->assertEquals($result['Aro']['parent_id'], 7);
$node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8), 'Aro'); $node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8), 'Aro');
$this->assertEquals(sizeof($node), 2); $this->assertEquals(count($node), 2);
$this->assertEquals($node[0]['Aro']['parent_id'], 7); $this->assertEquals($node[0]['Aro']['parent_id'], 7);
$this->assertEquals($node[1]['Aro']['parent_id'], null); $this->assertEquals($node[1]['Aro']['parent_id'], null);
} }
@ -362,7 +365,6 @@ class AclBehaviorTest extends CakeTestCase {
); );
$this->Aro->save($aroData); $this->Aro->save($aroData);
$acoData = array( $acoData = array(
'Aco' => array( 'Aco' => array(
'model' => 'AclPerson', 'model' => 'AclPerson',

View file

@ -19,7 +19,7 @@
App::uses('Model', 'Model'); App::uses('Model', 'Model');
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php'); require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/** /**
* ContainableTest class * ContainableTest class
@ -3553,8 +3553,10 @@ class ContainableBehaviorTest extends CakeTestCase {
$this->skipIf( $this->skipIf(
!isset($config->test) || !isset($config->test2), !isset($config->test) || !isset($config->test2),
'Primary and secondary test databases not configured, skipping cross-database join tests.' 'Primary and secondary test databases not configured, ' .
. ' To run these tests, you must define $test and $test2 in your database configuration.' 'skipping cross-database join tests. ' .
' To run these tests, you must define $test and $test2 ' .
'in your database configuration.'
); );
$db = ConnectionManager::getDataSource('test2'); $db = ConnectionManager::getDataSource('test2');

View file

@ -22,7 +22,7 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
App::uses('Model', 'Model'); App::uses('Model', 'Model');
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php'); require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/** /**
* TranslateBehaviorTest class * TranslateBehaviorTest class
@ -351,7 +351,6 @@ class TranslateBehaviorTest extends CakeTestCase {
$TestModel = new TranslatedItem(); $TestModel = new TranslatedItem();
$TestModel->locale = array('deu', 'eng', 'cze'); $TestModel->locale = array('deu', 'eng', 'cze');
$result = $TestModel->read(null, 1); $result = $TestModel->read(null, 1);
$expected = array( $expected = array(
'TranslatedItem' => array( 'TranslatedItem' => array(

View file

@ -19,7 +19,7 @@
App::uses('Model', 'Model'); App::uses('Model', 'Model');
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php'); require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/** /**

View file

@ -21,7 +21,7 @@
App::uses('Model', 'Model'); App::uses('Model', 'Model');
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php'); require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/** /**
* TreeBehaviorNumberTest class * TreeBehaviorNumberTest class
@ -42,7 +42,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
* *
* @var array * @var array
*/ */
protected $settings = array( public $settings = array(
'modelClass' => 'NumberTree', 'modelClass' => 'NumberTree',
'leftField' => 'lft', 'leftField' => 'lft',
'rightField' => 'rght', 'rightField' => 'rght',
@ -424,12 +424,12 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null; $this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id']; $parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id = $data[$modelClass]['id']; $this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id); $this->Tree->saveField($parentField, $parentId);
$direct = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField)); $direct = $this->Tree->children($parentId, true, array('id', 'name', $parentField, $leftField, $rightField));
$expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)), $expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)),
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)), array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)),
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13))); array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13)));
@ -450,14 +450,14 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null; $this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id']; $parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id = $data[$modelClass]['id']; $this->Tree->id = $data[$modelClass]['id'];
$this->Tree->whitelist = array($parentField, 'name', 'description'); $this->Tree->whitelist = array($parentField, 'name', 'description');
$this->Tree->saveField($parentField, $parent_id); $this->Tree->saveField($parentField, $parentId);
$result = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField)); $result = $this->Tree->children($parentId, true, array('id', 'name', $parentField, $leftField, $rightField));
$expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)), $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)),
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)), array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)),
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13))); array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13)));
@ -495,13 +495,13 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null; $this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1'))); $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1')));
$parent_id = $parent[$modelClass]['id']; $parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2')));
$this->Tree->id = $data[$modelClass]['id']; $this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id); $this->Tree->saveField($parentField, $parentId);
$result = $this->Tree->children($parent_id, true, array('name')); $result = $this->Tree->children($parentId, true, array('name'));
$expects = array(array($modelClass => array('name' => '1.1.1')), $expects = array(array($modelClass => array('name' => '1.1.1')),
array($modelClass => array('name' => '1.1.2')), array($modelClass => array('name' => '1.1.2')),
array($modelClass => array('name' => '1.2'))); array($modelClass => array('name' => '1.2')));
@ -523,13 +523,13 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null; $this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2'))); $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2')));
$parent_id = $parent[$modelClass]['id']; $parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
$this->Tree->id = $data[$modelClass]['id']; $this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id); $this->Tree->saveField($parentField, $parentId);
$result = $this->Tree->children($parent_id, true, array('name')); $result = $this->Tree->children($parentId, true, array('name'));
$expects = array(array($modelClass => array('name' => '1.2.1')), $expects = array(array($modelClass => array('name' => '1.2.1')),
array($modelClass => array('name' => '1.2.2')), array($modelClass => array('name' => '1.2.2')),
array($modelClass => array('name' => '1.1'))); array($modelClass => array('name' => '1.1')));
@ -551,15 +551,14 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null; $this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id']; $parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$expects = $this->Tree->find('all'); $expects = $this->Tree->find('all');
$before = $this->Tree->read(null, $data[$modelClass]['id']); $before = $this->Tree->read(null, $data[$modelClass]['id']);
$this->Tree->id = $parent_id; $this->Tree->id = $parentId;
//$this->expectError('Trying to save a node under itself in TreeBehavior::beforeSave');
$this->Tree->saveField($parentField, $data[$modelClass]['id']); $this->Tree->saveField($parentField, $data[$modelClass]['id']);
$results = $this->Tree->find('all'); $results = $this->Tree->find('all');
@ -586,11 +585,9 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$initialCount = $this->Tree->find('count'); $initialCount = $this->Tree->find('count');
$data = $this->Tree->findByName('1.1'); $data = $this->Tree->findByName('1.1');
//$this->expectError('Trying to save a node under a none-existant node in TreeBehavior::beforeSave');
$this->Tree->id = $data[$modelClass]['id']; $this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, 999999); $this->Tree->saveField($parentField, 999999);
//$this->assertSame($saveSuccess, false);
$laterCount = $this->Tree->find('count'); $laterCount = $this->Tree->find('count');
$this->assertSame($initialCount, $laterCount); $this->assertSame($initialCount, $laterCount);
@ -612,7 +609,6 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$initialCount = $this->Tree->find('count'); $initialCount = $this->Tree->find('count');
$data = $this->Tree->findByName('1.1'); $data = $this->Tree->findByName('1.1');
//$this->expectError('Trying to set a node to be the parent of itself in TreeBehavior::beforeSave');
$this->Tree->id = $data[$modelClass]['id']; $this->Tree->id = $data[$modelClass]['id'];
$saveSuccess = $this->Tree->saveField($parentField, $this->Tree->id); $saveSuccess = $this->Tree->saveField($parentField, $this->Tree->id);
@ -1036,9 +1032,11 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->assertEquals($initialCount - 1, $laterCount); $this->assertEquals($initialCount - 1, $laterCount);
$children = $this->Tree->children($result[$modelClass][$parentField], true, array('name'), $leftField . ' asc'); $children = $this->Tree->children($result[$modelClass][$parentField], true, array('name'), $leftField . ' asc');
$expects= array(array($modelClass => array('name' => '1.1.1')), $expects = array(
array($modelClass => array('name' => '1.1.1')),
array($modelClass => array('name' => '1.1.2')), array($modelClass => array('name' => '1.1.2')),
array($modelClass => array('name' => '1.2'))); array($modelClass => array('name' => '1.2'))
);
$this->assertEquals($children, $expects); $this->assertEquals($children, $expects);
$topNodes = $this->Tree->children(false, true,array('name')); $topNodes = $this->Tree->children(false, true,array('name'));

View file

@ -21,7 +21,7 @@
App::uses('Model', 'Model'); App::uses('Model', 'Model');
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php'); require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/** /**
* TreeBehaviorScopedTest class * TreeBehaviorScopedTest class

View file

@ -21,7 +21,7 @@
App::uses('Model', 'Model'); App::uses('Model', 'Model');
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php'); require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/** /**
* TreeBehaviorUuidTest class * TreeBehaviorUuidTest class
@ -68,12 +68,12 @@ class TreeBehaviorUuidTest extends CakeTestCase {
$this->Tree->id = null; $this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id']; $parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id = $data[$modelClass]['id']; $this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id); $this->Tree->saveField($parentField, $parentId);
$direct = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField)); $direct = $this->Tree->children($parentId, true, array('name', $leftField, $rightField));
$expects = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)), $expects = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)),
array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)), array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)),
array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13))); array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13)));
@ -94,14 +94,14 @@ class TreeBehaviorUuidTest extends CakeTestCase {
$this->Tree->id = null; $this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id']; $parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id = $data[$modelClass]['id']; $this->Tree->id = $data[$modelClass]['id'];
$this->Tree->whitelist = array($parentField, 'name', 'description'); $this->Tree->whitelist = array($parentField, 'name', 'description');
$this->Tree->saveField($parentField, $parent_id); $this->Tree->saveField($parentField, $parentId);
$result = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField)); $result = $this->Tree->children($parentId, true, array('name', $leftField, $rightField));
$expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)), $expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)),
array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)), array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)),
array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13))); array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13)));