Updating tests to use new find notation.

This commit is contained in:
Juan Basso 2011-02-25 21:26:35 -03:00
parent 7efe15393d
commit 4828e16762
3 changed files with 56 additions and 56 deletions

View file

@ -288,7 +288,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null))); $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)); $expected = array($modelClass => array('name' => 'testAddOrphan', $parentField => null));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
@ -307,7 +307,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(2, 2); $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'); $initialCount = $this->Tree->find('count');
$this->Tree->create(); $this->Tree->create();
@ -367,7 +367,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null)); $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)); $expected = array($modelClass => array('name' => 'testAddNotIndexed', $parentField => null));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
@ -387,10 +387,10 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $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']; $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->id= $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id); $this->Tree->saveField($parentField, $parent_id);
$direct = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField)); $direct = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField));
@ -414,10 +414,10 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $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']; $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->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, $parent_id);
@ -461,10 +461,10 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $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']; $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->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id); $this->Tree->saveField($parentField, $parent_id);
@ -490,10 +490,10 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $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']; $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->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id); $this->Tree->saveField($parentField, $parent_id);
@ -519,10 +519,10 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $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']; $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'); $expects = $this->Tree->find('all');
$before = $this->Tree->read(null, $data[$modelClass]['id']); $before = $this->Tree->read(null, $data[$modelClass]['id']);
@ -606,7 +606,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(2, 2); $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']); $this->Tree->moveUp($data[$modelClass]['id']);
$parent = $this->Tree->findByName('1. Root', array('id')); $parent = $this->Tree->findByName('1. Root', array('id'));
@ -628,7 +628,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(2, 2); $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']); $this->Tree->moveUp($data[$modelClass]['id']);
@ -651,7 +651,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(1, 10); $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); $this->Tree->moveUp($data[$modelClass]['id'], 2);
$parent = $this->Tree->findByName('1. Root', array('id')); $parent = $this->Tree->findByName('1. Root', array('id'));
@ -682,7 +682,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(1, 10); $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); $this->Tree->moveUp($data[$modelClass]['id'], true);
$parent = $this->Tree->findByName('1. Root', array('id')); $parent = $this->Tree->findByName('1. Root', array('id'));
@ -713,7 +713,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(2, 2); $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']); $this->Tree->moveDown($data[$modelClass]['id']);
$parent = $this->Tree->findByName('1. Root', array('id')); $parent = $this->Tree->findByName('1. Root', array('id'));
@ -735,7 +735,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(2, 2); $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']); $this->Tree->moveDown($data[$modelClass]['id']);
$parent = $this->Tree->findByName('1. Root', array('id')); $parent = $this->Tree->findByName('1. Root', array('id'));
@ -757,7 +757,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(1, 10); $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); $this->Tree->moveDown($data[$modelClass]['id'], true);
$parent = $this->Tree->findByName('1. Root', array('id')); $parent = $this->Tree->findByName('1. Root', array('id'));
@ -788,7 +788,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(1, 10); $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); $this->Tree->moveDown($data[$modelClass]['id'], 2);
$parent = $this->Tree->findByName('1. Root', array('id')); $parent = $this->Tree->findByName('1. Root', array('id'));
@ -819,7 +819,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(1, 10); $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->id = $data[$modelClass]['id'];
$this->Tree->saveField('name', 'renamed'); $this->Tree->saveField('name', 'renamed');
$parent = $this->Tree->findByName('1. Root', array('id')); $parent = $this->Tree->findByName('1. Root', array('id'));
@ -849,7 +849,7 @@ class NumberTreeTest extends CakeTestCase {
extract($this->settings); extract($this->settings);
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(1, 1); $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->id = $data[$modelClass]['id'];
$this->Tree->save(array($parentField => null)); $this->Tree->save(array($parentField => null));
@ -1077,7 +1077,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(2, 2); $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']; $this->Tree->id= $data[$modelClass]['id'];
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField)); $direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
@ -1108,7 +1108,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(2, 2); $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']; $this->Tree->id = $data[$modelClass]['id'];
$direct = $this->Tree->childCount(null, true); $direct = $this->Tree->childCount(null, true);
@ -1129,7 +1129,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(2, 2); $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']; $this->Tree->id= $data[$modelClass]['id'];
$result = $this->Tree->getParentNode(null, array('name')); $result = $this->Tree->getParentNode(null, array('name'));
@ -1148,7 +1148,7 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(2, 2); $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']; $this->Tree->id= $data[$modelClass]['id'];
$result = $this->Tree->getPath(null, array('name')); $result = $this->Tree->getPath(null, array('name'));
@ -1171,7 +1171,7 @@ class NumberTreeTest extends CakeTestCase {
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
$this->Tree->initialize(2, 2); $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']; $this->Tree->id= $data[$modelClass]['id'];
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField)); $direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
@ -1203,13 +1203,13 @@ class NumberTreeTest extends CakeTestCase {
$this->Tree->initialize(3, 3); $this->Tree->initialize(3, 3);
$nodes = $this->Tree->find('list', array('order' => $leftField)); $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']); $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']); $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']); $this->Tree->moveDown($data[$modelClass]['id']);
$unsortedNodes = $this->Tree->find('list', array('order' => $leftField)); $unsortedNodes = $this->Tree->find('list', array('order' => $leftField));
@ -1676,10 +1676,10 @@ class UuidTreeTest extends CakeTestCase {
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $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']; $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->id= $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id); $this->Tree->saveField($parentField, $parent_id);
$direct = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField)); $direct = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField));
@ -1702,10 +1702,10 @@ class UuidTreeTest extends CakeTestCase {
$this->Tree->initialize(2, 2); $this->Tree->initialize(2, 2);
$this->Tree->id = null; $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']; $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->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, $parent_id);
@ -1794,7 +1794,7 @@ class UuidTreeTest extends CakeTestCase {
$this->Tree = new $modelClass(); $this->Tree = new $modelClass();
$this->Tree->initialize(2, 2); $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']; $this->Tree->id = $data[$modelClass]['id'];
$direct = $this->Tree->children(null, true, array('name', $leftField, $rightField)); $direct = $this->Tree->children(null, true, array('name', $leftField, $rightField));
@ -1825,7 +1825,7 @@ class UuidTreeTest extends CakeTestCase {
$this->Tree->bindModel(array('belongsTo' => array('Dummy' => $this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); 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']; $this->Tree->id = $data[$modelClass]['id'];
$direct = $this->Tree->children(null, true, array('name', $leftField, $rightField)); $direct = $this->Tree->children(null, true, array('name', $leftField, $rightField));

View file

@ -5087,7 +5087,7 @@ class ModelReadTest extends BaseModelTest {
$this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio', 'Syfile', 'Image'); $this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio', 'Syfile', 'Image');
$Portfolio = new Portfolio(); $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( $expected = array(
'Portfolio' => array( 'Portfolio' => array(
'id' => 2, 'id' => 2,
@ -5725,7 +5725,7 @@ class ModelReadTest extends BaseModelTest {
$fullDebug = $this->db->fullDebug; $fullDebug = $this->db->fullDebug;
$this->db->fullDebug = true; $this->db->fullDebug = true;
$TestModel->recursive = 6; $TestModel->recursive = 6;
$result = $TestModel->find(array('CategoryThread.id' => 7)); $result = $TestModel->find('first', array('conditions' => array('CategoryThread.id' => 7)));
$expected = array( $expected = array(
'CategoryThread' => array( 'CategoryThread' => array(
@ -6007,12 +6007,12 @@ class ModelReadTest extends BaseModelTest {
function testConditionalNumerics() { function testConditionalNumerics() {
$this->loadFixtures('NumericArticle'); $this->loadFixtures('NumericArticle');
$NumericArticle = new NumericArticle(); $NumericArticle = new NumericArticle();
$data = array('title' => '12345abcde'); $data = array('conditions' => array('title' => '12345abcde'));
$result = $NumericArticle->find($data); $result = $NumericArticle->find('first', $data);
$this->assertTrue(!empty($result)); $this->assertTrue(!empty($result));
$data = array('title' => '12345'); $data = array('conditions' => array('title' => '12345'));
$result = $NumericArticle->find($data); $result = $NumericArticle->find('first', $data);
$this->assertTrue(empty($result)); $this->assertTrue(empty($result));
} }

View file

@ -105,7 +105,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $Article->save($data); $result = $Article->save($data);
$this->assertFalse(empty($result)); $this->assertFalse(empty($result));
$testResult = $Article->find(array('Article.title' => 'Test Title')); $testResult = $Article->find('first', array('conditions' => array('Article.title' => 'Test Title')));
$this->assertEqual($testResult['Article']['title'], $data['Article']['title']); $this->assertEqual($testResult['Article']['title'], $data['Article']['title']);
$this->assertEqual($testResult['Article']['created'], '2008-01-01 00:00:00'); $this->assertEqual($testResult['Article']['created'], '2008-01-01 00:00:00');
@ -1019,17 +1019,17 @@ class ModelWriteTest extends BaseModelTest {
$Article = new Article(); $Article = new Article();
$result = $Article->save(Xml::build('<article title="test xml" user_id="5" />')); $result = $Article->save(Xml::build('<article title="test xml" user_id="5" />'));
$this->assertFalse(empty($result)); $this->assertFalse(empty($result));
$results = $Article->find(array('Article.title' => 'test xml')); $results = $Article->find('first', array('conditions' => array('Article.title' => 'test xml')));
$this->assertFalse(empty($results)); $this->assertFalse(empty($results));
$result = $Article->save(Xml::build('<article><title>testing</title><user_id>6</user_id></article>')); $result = $Article->save(Xml::build('<article><title>testing</title><user_id>6</user_id></article>'));
$this->assertFalse(empty($result)); $this->assertFalse(empty($result));
$results = $Article->find(array('Article.title' => 'testing')); $results = $Article->find('first', array('conditions' => array('Article.title' => 'testing')));
$this->assertFalse(empty($results)); $this->assertFalse(empty($results));
$result = $Article->save(Xml::build('<article><title>testing with DOMDocument</title><user_id>7</user_id></article>', array('return' => 'domdocument'))); $result = $Article->save(Xml::build('<article><title>testing with DOMDocument</title><user_id>7</user_id></article>', array('return' => 'domdocument')));
$this->assertFalse(empty($result)); $this->assertFalse(empty($result));
$results = $Article->find(array('Article.title' => 'testing with DOMDocument')); $results = $Article->find('first', array('conditions' => array('Article.title' => 'testing with DOMDocument')));
$this->assertFalse(empty($results)); $this->assertFalse(empty($results));
} }
@ -1111,7 +1111,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertFalse(empty($result)); $this->assertFalse(empty($result));
$TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment'))); $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
$result = $TestModel->find(array('Article.id' => 2), array('id', 'user_id', 'title', 'body')); $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
$expected = array( $expected = array(
'Article' => array( 'Article' => array(
'id' => '2', 'id' => '2',
@ -1145,7 +1145,7 @@ class ModelWriteTest extends BaseModelTest {
'belongsTo' => array('User'), 'belongsTo' => array('User'),
'hasMany' => array('Comment') 'hasMany' => array('Comment')
)); ));
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
$expected = array( $expected = array(
'Article' => array( 'Article' => array(
'id' => '2', 'id' => '2',
@ -1180,7 +1180,7 @@ class ModelWriteTest extends BaseModelTest {
'belongsTo' => array('User'), 'belongsTo' => array('User'),
'hasMany' => array('Comment') 'hasMany' => array('Comment')
)); ));
$result = $TestModel->find(array('Article.id' => 2), array('id', 'user_id', 'title', 'body')); $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
$expected = array( $expected = array(
'Article' => array( 'Article' => array(
'id' => '2', 'id' => '2',
@ -1227,7 +1227,7 @@ class ModelWriteTest extends BaseModelTest {
'belongsTo' => array('User'), 'belongsTo' => array('User'),
'hasMany' => array('Comment') 'hasMany' => array('Comment')
)); ));
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
$expected = array( $expected = array(
'Article' => array( 'Article' => array(
'id' => '2', 'id' => '2',
@ -1250,7 +1250,7 @@ class ModelWriteTest extends BaseModelTest {
'belongsTo' => array('User'), 'belongsTo' => array('User'),
'hasMany' => array('Comment') 'hasMany' => array('Comment')
)); ));
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
$expected = array( $expected = array(
'Article' => array( 'Article' => array(
'id' => '2', 'id' => '2',
@ -1290,7 +1290,7 @@ class ModelWriteTest extends BaseModelTest {
'belongsTo' => array('User'), 'belongsTo' => array('User'),
'hasMany' => array('Comment') 'hasMany' => array('Comment')
)); ));
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
$expected = array( $expected = array(
'Article' => array( 'Article' => array(
'id' => '2', 'id' => '2',
@ -1330,7 +1330,7 @@ class ModelWriteTest extends BaseModelTest {
'belongsTo' => array('User'), 'belongsTo' => array('User'),
'hasMany' => array('Comment') 'hasMany' => array('Comment')
)); ));
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
$expected = array( $expected = array(
'Article' => array( 'Article' => array(
'id' => '2', 'id' => '2',
@ -1372,7 +1372,7 @@ class ModelWriteTest extends BaseModelTest {
'belongsTo' => array('User'), 'belongsTo' => array('User'),
'hasMany' => array('Comment') 'hasMany' => array('Comment')
)); ));
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
$expected = array( $expected = array(
'Article' => array( 'Article' => array(
'id' => '2', 'id' => '2',
@ -1414,7 +1414,7 @@ class ModelWriteTest extends BaseModelTest {
'belongsTo' => array('User'), 'belongsTo' => array('User'),
'hasMany' => array('Comment') 'hasMany' => array('Comment')
)); ));
$result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));
$expected = array( $expected = array(
'Article' => array( 'Article' => array(
'id' => '2', 'id' => '2',