Skip to content

Commit 3dc12cb

Browse files
committed
Updating model tests to reflect deprecation of Model::bind() and Model::delete() aliases.
1 parent 9afa4d1 commit 3dc12cb

3 files changed

Lines changed: 34 additions & 20 deletions

File tree

cake/tests/cases/libs/model/behaviors/containable.test.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ function startTest() {
5757
$this->Article =& ClassRegistry::init('Article');
5858
$this->Tag =& ClassRegistry::init('Tag');
5959

60-
$this->User->bind(array(
61-
'Article' => array('type' => 'hasMany'),
62-
'ArticleFeatured' => array('type' => 'hasMany'),
63-
'Comment' => array('type' => 'hasMany')
64-
));
60+
$this->User->bindModel(array(
61+
'hasMany' => array('Article', 'ArticleFeatured', 'Comment')
62+
), false);
6563
$this->User->ArticleFeatured->unbindModel(array('belongsTo' => array('Category')), false);
6664
$this->User->ArticleFeatured->hasMany['Comment']['foreignKey'] = 'article_id';
6765

68-
$this->Tag->bind(array(
69-
'Article' => array('type' => 'hasAndBelongsToMany')
70-
));
66+
$this->Tag->bindModel(array(
67+
'hasAndBelongsToMany' => array('Article')
68+
), false);
7169

7270
$this->User->Behaviors->attach('Containable');
7371
$this->Article->Behaviors->attach('Containable');

cake/tests/cases/libs/model/model_read.test.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4519,25 +4519,39 @@ function testBindUnbind() {
45194519
);
45204520
$this->assertEqual($TestModel2->belongsTo['FeatureSet'], $expected);
45214521

4522-
$TestModel2->bind('FeatureSet', array(
4523-
'conditions' => array('active' => true)
4522+
$TestModel2->bindModel(array(
4523+
'belongsTo' => array(
4524+
'FeatureSet' => array(
4525+
'className' => 'FeatureSet',
4526+
'conditions' => array('active' => true)
4527+
)
4528+
)
45244529
));
45254530
$expected['conditions'] = array('active' => true);
45264531
$this->assertEqual($TestModel2->belongsTo['FeatureSet'], $expected);
45274532

4528-
$TestModel2->bind('FeatureSet', array(
4529-
'foreignKey' => false,
4530-
'conditions' => array('Feature.name' => 'DeviceType.name')
4533+
$TestModel2->bindModel(array(
4534+
'belongsTo' => array(
4535+
'FeatureSet' => array(
4536+
'className' => 'FeatureSet',
4537+
'foreignKey' => false,
4538+
'conditions' => array('Feature.name' => 'DeviceType.name')
4539+
)
4540+
)
45314541
));
45324542
$expected['conditions'] = array('Feature.name' => 'DeviceType.name');
45334543
$expected['foreignKey'] = false;
45344544
$this->assertEqual($TestModel2->belongsTo['FeatureSet'], $expected);
45354545

4536-
$TestModel2->bind('NewFeatureSet', array(
4537-
'type' => 'hasMany',
4538-
'className' => 'FeatureSet',
4539-
'conditions' => array('active' => true)
4546+
$TestModel2->bindModel(array(
4547+
'hasMany' => array(
4548+
'NewFeatureSet' => array(
4549+
'className' => 'FeatureSet',
4550+
'conditions' => array('active' => true)
4551+
)
4552+
)
45404553
));
4554+
45414555
$expected = array(
45424556
'className' => 'FeatureSet',
45434557
'conditions' => array('active' => true),

cake/tests/cases/libs/model/model_write.test.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ function testZeroDefaultFieldValue() {
200200
function testNonNumericHabtmJoinKey() {
201201
$this->loadFixtures('Post', 'Tag', 'PostsTag');
202202
$Post =& new Post();
203-
$Post->bind('Tag', array('type' => 'hasAndBelongsToMany'));
203+
$Post->bindModel(array(
204+
'hasAndBelongsToMany' => array('Tag')
205+
));
204206
$Post->Tag->primaryKey = 'tag';
205207

206208
$result = $Post->find('all');
@@ -423,7 +425,7 @@ function testCounterCacheDecrease() {
423425
$User = new CounterCacheUser();
424426
$Post = new CounterCachePost();
425427

426-
$Post->del(2);
428+
$Post->delete(2);
427429
$user = $User->find('first', array(
428430
'conditions' => array('id' => 66),
429431
'recursive' => -1
@@ -3086,7 +3088,7 @@ function testSaveAllHasOneValidation() {
30863088

30873089
$model->validate = array('comment' => 'notEmpty');
30883090
$model->Attachment->validate = array('attachment' => 'notEmpty');
3089-
$model->Attachment->bind('Comment');
3091+
$model->Attachment->bindModel(array('belongsTo' => array('Comment')));
30903092

30913093
$this->assertFalse($model->saveAll(
30923094
array(

0 commit comments

Comments
 (0)