Skip to content

Commit

Permalink
Updating tests to use new find notation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Feb 26, 2011
1 parent 7efe153 commit 4828e16
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 56 deletions.
74 changes: 37 additions & 37 deletions cake/tests/cases/libs/model/behaviors/tree.test.php
Expand Up @@ -288,7 +288,7 @@ function testAddOrphan() {
$this->Tree->initialize(2, 2);

$this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null)));
$result = $this->Tree->find(null, array('name', $parentField), $modelClass . '.' . $leftField . ' desc');
$result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc'));
$expected = array($modelClass => array('name' => 'testAddOrphan', $parentField => null));
$this->assertEqual($result, $expected);

Expand All @@ -307,7 +307,7 @@ function testAddMiddle() {
$this->Tree = new $modelClass();
$this->Tree->initialize(2, 2);

$data= $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
$initialCount = $this->Tree->find('count');

$this->Tree->create();
Expand Down Expand Up @@ -367,7 +367,7 @@ function testAddNotIndexedByModel() {
$this->Tree->initialize(2, 2);

$this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null));
$result = $this->Tree->find(null, array('name', $parentField), $modelClass . '.' . $leftField . ' desc');
$result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc'));
$expected = array($modelClass => array('name' => 'testAddNotIndexed', $parentField => null));
$this->assertEqual($result, $expected);

Expand All @@ -387,10 +387,10 @@ function testMovePromote() {
$this->Tree->initialize(2, 2);
$this->Tree->id = null;

$parent = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id'];

$data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id= $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id);
$direct = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField));
Expand All @@ -414,10 +414,10 @@ function testMoveWithWhitelist() {
$this->Tree->initialize(2, 2);
$this->Tree->id = null;

$parent = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id'];

$data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->whitelist = array($parentField, 'name', 'description');
$this->Tree->saveField($parentField, $parent_id);
Expand Down Expand Up @@ -461,10 +461,10 @@ function testMoveBefore() {
$this->Tree->initialize(2, 2);
$this->Tree->id = null;

$parent = $this->Tree->find(array($modelClass . '.name' => '1.1'));
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1')));
$parent_id = $parent[$modelClass]['id'];

$data= $this->Tree->find(array($modelClass . '.name' => '1.2'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2')));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id);

Expand All @@ -490,10 +490,10 @@ function testMoveAfter() {
$this->Tree->initialize(2, 2);
$this->Tree->id = null;

$parent = $this->Tree->find(array($modelClass . '.name' => '1.2'));
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2')));
$parent_id = $parent[$modelClass]['id'];

$data= $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id'));
$data= $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id);

Expand All @@ -519,10 +519,10 @@ function testMoveDemoteInvalid() {
$this->Tree->initialize(2, 2);
$this->Tree->id = null;

$parent = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id'];

$data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));

$expects = $this->Tree->find('all');
$before = $this->Tree->read(null, $data[$modelClass]['id']);
Expand Down Expand Up @@ -606,7 +606,7 @@ function testMoveUpSuccess() {
$this->Tree = new $modelClass();
$this->Tree->initialize(2, 2);

$data = $this->Tree->find(array($modelClass . '.name' => '1.2'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2')));
$this->Tree->moveUp($data[$modelClass]['id']);

$parent = $this->Tree->findByName('1. Root', array('id'));
Expand All @@ -628,7 +628,7 @@ function testMoveUpFail() {
$this->Tree = new $modelClass();
$this->Tree->initialize(2, 2);

$data = $this->Tree->find(array($modelClass . '.name' => '1.1'));
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1')));

$this->Tree->moveUp($data[$modelClass]['id']);

Expand All @@ -651,7 +651,7 @@ function testMoveUp2() {
$this->Tree = new $modelClass();
$this->Tree->initialize(1, 10);

$data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
$this->Tree->moveUp($data[$modelClass]['id'], 2);

$parent = $this->Tree->findByName('1. Root', array('id'));
Expand Down Expand Up @@ -682,7 +682,7 @@ function testMoveUpFirst() {
$this->Tree = new $modelClass();
$this->Tree->initialize(1, 10);

$data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
$this->Tree->moveUp($data[$modelClass]['id'], true);

$parent = $this->Tree->findByName('1. Root', array('id'));
Expand Down Expand Up @@ -713,7 +713,7 @@ function testMoveDownSuccess() {
$this->Tree = new $modelClass();
$this->Tree->initialize(2, 2);

$data = $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
$this->Tree->moveDown($data[$modelClass]['id']);

$parent = $this->Tree->findByName('1. Root', array('id'));
Expand All @@ -735,7 +735,7 @@ function testMoveDownFail() {
$this->Tree = new $modelClass();
$this->Tree->initialize(2, 2);

$data = $this->Tree->find(array($modelClass . '.name' => '1.2'));
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2')));
$this->Tree->moveDown($data[$modelClass]['id']);

$parent = $this->Tree->findByName('1. Root', array('id'));
Expand All @@ -757,7 +757,7 @@ function testMoveDownLast() {
$this->Tree = new $modelClass();
$this->Tree->initialize(1, 10);

$data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
$this->Tree->moveDown($data[$modelClass]['id'], true);

$parent = $this->Tree->findByName('1. Root', array('id'));
Expand Down Expand Up @@ -788,7 +788,7 @@ function testMoveDown2() {
$this->Tree = new $modelClass();
$this->Tree->initialize(1, 10);

$data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
$this->Tree->moveDown($data[$modelClass]['id'], 2);

$parent = $this->Tree->findByName('1. Root', array('id'));
Expand Down Expand Up @@ -819,7 +819,7 @@ function testSaveNoMove() {
$this->Tree = new $modelClass();
$this->Tree->initialize(1, 10);

$data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField('name', 'renamed');
$parent = $this->Tree->findByName('1. Root', array('id'));
Expand Down Expand Up @@ -849,7 +849,7 @@ function testMoveToRootAndMoveUp() {
extract($this->settings);
$this->Tree = new $modelClass();
$this->Tree->initialize(1, 1);
$data = $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->save(array($parentField => null));

Expand Down Expand Up @@ -1077,7 +1077,7 @@ function testChildren() {
$this->Tree = new $modelClass();
$this->Tree->initialize(2, 2);

$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$this->Tree->id= $data[$modelClass]['id'];

$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
Expand Down Expand Up @@ -1108,7 +1108,7 @@ function testCountChildren() {
$this->Tree = new $modelClass();
$this->Tree->initialize(2, 2);

$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$this->Tree->id = $data[$modelClass]['id'];

$direct = $this->Tree->childCount(null, true);
Expand All @@ -1129,7 +1129,7 @@ function testGetParentNode() {
$this->Tree = new $modelClass();
$this->Tree->initialize(2, 2);

$data = $this->Tree->find(array($modelClass . '.name' => '1.2.2'));
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
$this->Tree->id= $data[$modelClass]['id'];

$result = $this->Tree->getParentNode(null, array('name'));
Expand All @@ -1148,7 +1148,7 @@ function testGetPath() {
$this->Tree = new $modelClass();
$this->Tree->initialize(2, 2);

$data = $this->Tree->find(array($modelClass . '.name' => '1.2.2'));
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
$this->Tree->id= $data[$modelClass]['id'];

$result = $this->Tree->getPath(null, array('name'));
Expand All @@ -1171,7 +1171,7 @@ function testNoAmbiguousColumn() {
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
$this->Tree->initialize(2, 2);

$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$this->Tree->id= $data[$modelClass]['id'];

$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
Expand Down Expand Up @@ -1203,13 +1203,13 @@ function testReorderTree() {
$this->Tree->initialize(3, 3);
$nodes = $this->Tree->find('list', array('order' => $leftField));

$data = $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
$this->Tree->moveDown($data[$modelClass]['id']);

$data = $this->Tree->find(array($modelClass . '.name' => '1.2.1'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2.1')));
$this->Tree->moveDown($data[$modelClass]['id']);

$data = $this->Tree->find(array($modelClass . '.name' => '1.3.2.2'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.3.2.2')));
$this->Tree->moveDown($data[$modelClass]['id']);

$unsortedNodes = $this->Tree->find('list', array('order' => $leftField));
Expand Down Expand Up @@ -1676,10 +1676,10 @@ public function testMovePromote() {
$this->Tree->initialize(2, 2);
$this->Tree->id = null;

$parent = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id'];

$data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id= $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id);
$direct = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField));
Expand All @@ -1702,10 +1702,10 @@ public function testMoveWithWhitelist() {
$this->Tree->initialize(2, 2);
$this->Tree->id = null;

$parent = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id'];

$data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id'));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->whitelist = array($parentField, 'name', 'description');
$this->Tree->saveField($parentField, $parent_id);
Expand Down Expand Up @@ -1794,7 +1794,7 @@ public function testChildren() {
$this->Tree = new $modelClass();
$this->Tree->initialize(2, 2);

$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$this->Tree->id = $data[$modelClass]['id'];

$direct = $this->Tree->children(null, true, array('name', $leftField, $rightField));
Expand Down Expand Up @@ -1825,7 +1825,7 @@ public function testNoAmbiguousColumn() {
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);

$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$this->Tree->id = $data[$modelClass]['id'];

$direct = $this->Tree->children(null, true, array('name', $leftField, $rightField));
Expand Down
12 changes: 6 additions & 6 deletions cake/tests/cases/libs/model/model_read.test.php
Expand Up @@ -5087,7 +5087,7 @@ function testHabtmRecursiveBelongsTo() {
$this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio', 'Syfile', 'Image');
$Portfolio = new Portfolio();

$result = $Portfolio->find(array('id' => 2), null, null, 3);
$result = $Portfolio->find('first', array('conditions' => array('id' => 2), 'recursive' => 3));
$expected = array(
'Portfolio' => array(
'id' => 2,
Expand Down Expand Up @@ -5725,7 +5725,7 @@ function testFindFakeThread() {
$fullDebug = $this->db->fullDebug;
$this->db->fullDebug = true;
$TestModel->recursive = 6;
$result = $TestModel->find(array('CategoryThread.id' => 7));
$result = $TestModel->find('first', array('conditions' => array('CategoryThread.id' => 7)));

$expected = array(
'CategoryThread' => array(
Expand Down Expand Up @@ -6007,12 +6007,12 @@ function testFindAllFakeThread() {
function testConditionalNumerics() {
$this->loadFixtures('NumericArticle');
$NumericArticle = new NumericArticle();
$data = array('title' => '12345abcde');
$result = $NumericArticle->find($data);
$data = array('conditions' => array('title' => '12345abcde'));
$result = $NumericArticle->find('first', $data);
$this->assertTrue(!empty($result));

$data = array('title' => '12345');
$result = $NumericArticle->find($data);
$data = array('conditions' => array('title' => '12345'));
$result = $NumericArticle->find('first', $data);
$this->assertTrue(empty($result));
}

Expand Down

0 comments on commit 4828e16

Please sign in to comment.