From b5bd087bc5c8fc8ca635ffb2b54cb6bbdc86dd47 Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 8 Oct 2013 20:23:57 +0200 Subject: [PATCH] Replace deprecated methods. --- .../Behavior/ContainableBehaviorTest.php | 22 +-- .../Model/Behavior/TranslateBehaviorTest.php | 12 +- .../Model/Behavior/TreeBehaviorNumberTest.php | 2 +- .../Model/Behavior/TreeBehaviorScopedTest.php | 30 ++-- .../Case/Model/BehaviorCollectionTest.php | 164 +++++++++--------- .../Test/Case/Model/ModelIntegrationTest.php | 6 +- .../Test/Case/Model/ModelValidationTest.php | 4 +- 7 files changed, 120 insertions(+), 120 deletions(-) diff --git a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php index dc0e44b6e99..802ca94c686 100644 --- a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php @@ -61,9 +61,9 @@ public function setUp() { 'hasAndBelongsToMany' => array('Article') ), false); - $this->User->Behaviors->attach('Containable'); - $this->Article->Behaviors->attach('Containable'); - $this->Tag->Behaviors->attach('Containable'); + $this->User->Behaviors->load('Containable'); + $this->Article->Behaviors->load('Containable'); + $this->Tag->Behaviors->load('Containable'); } /** @@ -162,7 +162,7 @@ public function testInvalidContainments() { * @return void */ public function testInvalidContainmentsNoNotices() { - $this->Article->Behaviors->attach('Containable', array('notices' => false)); + $this->Article->Behaviors->load('Containable', array('notices' => false)); $this->_containments($this->Article, array('Comment', 'InvalidBinding')); } @@ -3241,7 +3241,7 @@ public function testOtherFinds() { * @return void */ public function testOriginalAssociations() { - $this->Article->Comment->Behaviors->attach('Containable'); + $this->Article->Comment->Behaviors->load('Containable'); $options = array( 'conditions' => array( @@ -3356,9 +3356,9 @@ public function testResetAddedAssociation() { $this->JoinB = ClassRegistry::init('JoinB'); $this->JoinC = ClassRegistry::init('JoinC'); - $this->JoinA->Behaviors->attach('Containable'); - $this->JoinB->Behaviors->attach('Containable'); - $this->JoinC->Behaviors->attach('Containable'); + $this->JoinA->Behaviors->load('Containable'); + $this->JoinB->Behaviors->load('Containable'); + $this->JoinC->Behaviors->load('Containable'); $this->JoinA->JoinB->find('all', array('contain' => array('JoinA'))); $this->JoinA->bindModel(array('hasOne' => array('JoinAsJoinC' => array('joinTable' => 'as_cs'))), false); @@ -3373,9 +3373,9 @@ public function testResetAddedAssociation() { * */ public function testResetAssociation() { - $this->Article->Behaviors->attach('Containable'); - $this->Article->Comment->Behaviors->attach('Containable'); - $this->Article->User->Behaviors->attach('Containable'); + $this->Article->Behaviors->load('Containable'); + $this->Article->Comment->Behaviors->load('Containable'); + $this->Article->User->Behaviors->load('Containable'); $initialOptions = array( 'conditions' => array( diff --git a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php index bd1462968d4..f90526ed704 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php @@ -69,13 +69,13 @@ public function testTranslateModel() { $this->loadFixtures('TranslateTable', 'Tag', 'TranslatedItem', 'Translate', 'User', 'TranslatedArticle', 'TranslateArticle'); $TestModel = new Tag(); $TestModel->translateTable = 'another_i18n'; - $TestModel->Behaviors->attach('Translate', array('title')); + $TestModel->Behaviors->load('Translate', array('title')); $translateModel = $TestModel->Behaviors->Translate->translateModel($TestModel); $this->assertEquals('I18nModel', $translateModel->name); $this->assertEquals('another_i18n', $translateModel->useTable); $TestModel = new User(); - $TestModel->Behaviors->attach('Translate', array('title')); + $TestModel->Behaviors->load('Translate', array('title')); $translateModel = $TestModel->Behaviors->Translate->translateModel($TestModel); $this->assertEquals('I18nModel', $translateModel->name); $this->assertEquals('i18n', $translateModel->useTable); @@ -989,7 +989,7 @@ public function testAttachDetach() { $expected = array('Title', 'Content'); $this->assertEquals($expected, $result); - $TestModel->Behaviors->detach('Translate'); + $TestModel->Behaviors->unload('Translate'); $result = array_keys($TestModel->hasMany); $expected = array(); $this->assertEquals($expected, $result); @@ -1003,7 +1003,7 @@ public function testAttachDetach() { $result = isset($Behavior->runtime[$TestModel->alias]); $this->assertFalse($result); - $TestModel->Behaviors->attach('Translate', array('title' => 'Title', 'content' => 'Content')); + $TestModel->Behaviors->load('Translate', array('title' => 'Title', 'content' => 'Content')); $result = array_keys($TestModel->hasMany); $expected = array('Title', 'Content'); $this->assertEquals($expected, $result); @@ -1185,9 +1185,9 @@ public function testUnbindTranslationInfinteLoop() { $this->loadFixtures('Translate', 'TranslatedItem'); $TestModel = new TranslatedItem(); - $TestModel->Behaviors->detach('Translate'); + $TestModel->Behaviors->unload('Translate'); $TestModel->actsAs = array(); - $TestModel->Behaviors->attach('Translate'); + $TestModel->Behaviors->load('Translate'); $TestModel->bindTranslation(array('title', 'content'), true); $result = $TestModel->unbindTranslation(); diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php index f8676835a4d..baf0d038820 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php @@ -1486,7 +1486,7 @@ public function testArraySyntax() { public function testFindThreaded() { $Model = new Person(); $Model->recursive = -1; - $Model->Behaviors->attach('Tree', array('parent' => 'mother_id')); + $Model->Behaviors->load('Tree', array('parent' => 'mother_id')); $result = $Model->find('threaded'); $expected = array( diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php index 530e6825c23..92f93ab0730 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php @@ -80,11 +80,11 @@ public function testStringScope() { ); $this->assertEquals($expected, $result); - $this->Tree->Behaviors->attach('Tree', array('scope' => 'FlagTree.flag = 1')); + $this->Tree->Behaviors->load('Tree', array('scope' => 'FlagTree.flag = 1')); $this->assertEquals(array(), $this->Tree->children()); $this->Tree->id = 1; - $this->Tree->Behaviors->attach('Tree', array('scope' => 'FlagTree.flag = 1')); + $this->Tree->Behaviors->load('Tree', array('scope' => 'FlagTree.flag = 1')); $result = $this->Tree->children(); $expected = array(array('FlagTree' => array('id' => '2', 'name' => '1.1', 'parent_id' => '1', 'lft' => '2', 'rght' => '9', 'flag' => '1'))); @@ -117,11 +117,11 @@ public function testArrayScope() { ); $this->assertEquals($expected, $result); - $this->Tree->Behaviors->attach('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); $this->assertEquals(array(), $this->Tree->children()); $this->Tree->id = 1; - $this->Tree->Behaviors->attach('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); $result = $this->Tree->children(); $expected = array(array('FlagTree' => array('id' => '2', 'name' => '1.1', 'parent_id' => '1', 'lft' => '2', 'rght' => '9', 'flag' => '1'))); @@ -139,7 +139,7 @@ public function testArrayScope() { public function testMoveUpWithScope() { $this->Ad = new Ad(); $this->Ad->order = null; - $this->Ad->Behaviors->attach('Tree', array('scope' => 'Campaign')); + $this->Ad->Behaviors->load('Tree', array('scope' => 'Campaign')); $this->Ad->moveUp(6); $this->Ad->id = 4; @@ -156,7 +156,7 @@ public function testMoveUpWithScope() { public function testMoveDownWithScope() { $this->Ad = new Ad(); $this->Ad->order = null; - $this->Ad->Behaviors->attach('Tree', array('scope' => 'Campaign')); + $this->Ad->Behaviors->load('Tree', array('scope' => 'Campaign')); $this->Ad->moveDown(6); $this->Ad->id = 4; @@ -175,7 +175,7 @@ public function testTranslatingTree() { $this->Tree = new FlagTree(); $this->Tree->order = null; $this->Tree->cacheQueries = false; - $this->Tree->Behaviors->attach('Translate', array('title')); + $this->Tree->Behaviors->load('Translate', array('title')); //Save $this->Tree->create(); @@ -316,7 +316,7 @@ public function testAliasesWithScopeInTwoTreeAssociations() { ) ) )); - $this->TreeTwo->Behaviors->attach('Tree', array( + $this->TreeTwo->Behaviors->load('Tree', array( 'scope' => 'FirstTree' )); @@ -358,7 +358,7 @@ public function testGenerateTreeListWithScope() { $this->Tree->id = 2; $this->Tree->saveField('flag', 1); - $this->Tree->Behaviors->attach('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); $result = $this->Tree->generateTreeList(); $expected = array( @@ -368,7 +368,7 @@ public function testGenerateTreeListWithScope() { $this->assertEquals($expected, $result); // As string. - $this->Tree->Behaviors->attach('Tree', array('scope' => 'FlagTree.flag = 1')); + $this->Tree->Behaviors->load('Tree', array('scope' => 'FlagTree.flag = 1')); $result = $this->Tree->generateTreeList(); $this->assertEquals($expected, $result); @@ -392,7 +392,7 @@ public function testRecoverUsingParentMode() { $this->Tree->order = null; $this->Tree->initialize(2, 3); - $this->Tree->Behaviors->attach('Tree', array('scope' => 'FlagTree.flag = 1')); + $this->Tree->Behaviors->load('Tree', array('scope' => 'FlagTree.flag = 1')); $this->Tree->Behaviors->disable('Tree'); $this->Tree->create(); @@ -457,7 +457,7 @@ public function testRecoverFromMissingParent() { $this->Tree->id = 2; $this->Tree->saveField('flag', 1); - $this->Tree->Behaviors->attach('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); $result = $this->Tree->findByName('1.1'); $this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id'])); @@ -488,7 +488,7 @@ public function testDetectInvalidParents() { $this->Tree->id = 2; $this->Tree->saveField('flag', 1); - $this->Tree->Behaviors->attach('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); $this->Tree->updateAll(array($parentField => null)); @@ -518,7 +518,7 @@ public function testDetectInvalidLftsRghts() { $this->Tree->id = 2; $this->Tree->saveField('flag', 1); - $this->Tree->Behaviors->attach('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); $this->Tree->updateAll(array($leftField => 0, $rightField => 0)); @@ -547,7 +547,7 @@ public function testDetectEqualLftsRghts() { $this->Tree->id = 2; $this->Tree->saveField('flag', 1); - $this->Tree->Behaviors->attach('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); $result = $this->Tree->findByName('1.1'); $this->Tree->updateAll(array($rightField => $result[$modelClass][$leftField]), array('id' => $result[$modelClass]['id'])); diff --git a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php index a506c28f91a..5bb17350398 100644 --- a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php +++ b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php @@ -523,7 +523,7 @@ public function testBehaviorBinding() { $Apple = new Apple(); $this->assertSame(array(), $Apple->Behaviors->loaded()); - $Apple->Behaviors->attach('Test', array('key' => 'value')); + $Apple->Behaviors->load('Test', array('key' => 'value')); $this->assertSame(array('Test'), $Apple->Behaviors->loaded()); $this->assertEquals('testbehavior', strtolower(get_class($Apple->Behaviors->Test))); $expected = array('beforeFind' => 'on', 'afterFind' => 'off', 'key' => 'value'); @@ -531,7 +531,7 @@ public function testBehaviorBinding() { $this->assertEquals(array('priority', 'Apple'), array_keys($Apple->Behaviors->Test->settings)); $this->assertSame($Apple->Sample->Behaviors->loaded(), array()); - $Apple->Sample->Behaviors->attach('Test', array('key2' => 'value2')); + $Apple->Sample->Behaviors->load('Test', array('key2' => 'value2')); $this->assertSame($Apple->Sample->Behaviors->loaded(), array('Test')); $this->assertEquals(array('beforeFind' => 'on', 'afterFind' => 'off', 'key2' => 'value2'), $Apple->Sample->Behaviors->Test->settings['Sample']); @@ -542,23 +542,23 @@ public function testBehaviorBinding() { ); $this->assertNotSame($Apple->Behaviors->Test->settings['Apple'], $Apple->Sample->Behaviors->Test->settings['Sample']); - $Apple->Behaviors->attach('Test', array('key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off')); - $Apple->Sample->Behaviors->attach('Test', array('key' => 'value', 'key3' => 'value3', 'beforeFind' => 'off')); + $Apple->Behaviors->load('Test', array('key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off')); + $Apple->Sample->Behaviors->load('Test', array('key' => 'value', 'key3' => 'value3', 'beforeFind' => 'off')); $this->assertEquals(array('beforeFind' => 'off', 'afterFind' => 'off', 'key' => 'value', 'key2' => 'value2', 'key3' => 'value3'), $Apple->Behaviors->Test->settings['Apple']); $this->assertEquals($Apple->Behaviors->Test->settings['Apple'], $Apple->Sample->Behaviors->Test->settings['Sample']); $this->assertFalse(isset($Apple->Child->Behaviors->Test)); - $Apple->Child->Behaviors->attach('Test', array('key' => 'value', 'key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off')); + $Apple->Child->Behaviors->load('Test', array('key' => 'value', 'key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off')); $this->assertEquals($Apple->Child->Behaviors->Test->settings['Child'], $Apple->Sample->Behaviors->Test->settings['Sample']); $this->assertFalse(isset($Apple->Parent->Behaviors->Test)); - $Apple->Parent->Behaviors->attach('Test', array('key' => 'value', 'key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off')); + $Apple->Parent->Behaviors->load('Test', array('key' => 'value', 'key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off')); $this->assertEquals($Apple->Parent->Behaviors->Test->settings['Parent'], $Apple->Sample->Behaviors->Test->settings['Sample']); - $Apple->Parent->Behaviors->attach('Test', array('key' => 'value', 'key2' => 'value', 'key3' => 'value', 'beforeFind' => 'off')); + $Apple->Parent->Behaviors->load('Test', array('key' => 'value', 'key2' => 'value', 'key3' => 'value', 'beforeFind' => 'off')); $this->assertNotEquals($Apple->Parent->Behaviors->Test->settings['Parent'], $Apple->Sample->Behaviors->Test->settings['Sample']); - $Apple->Behaviors->attach('Plugin.Test', array('key' => 'new value')); + $Apple->Behaviors->load('Plugin.Test', array('key' => 'new value')); $expected = array( 'beforeFind' => 'off', 'afterFind' => 'off', 'key' => 'new value', 'key2' => 'value2', 'key3' => 'value3' @@ -567,14 +567,14 @@ public function testBehaviorBinding() { $current = $Apple->Behaviors->Test->settings['Apple']; $expected = array_merge($current, array('mangle' => 'trigger mangled')); - $Apple->Behaviors->attach('Test', array('mangle' => 'trigger')); + $Apple->Behaviors->load('Test', array('mangle' => 'trigger')); $this->assertEquals($expected, $Apple->Behaviors->Test->settings['Apple']); - $Apple->Behaviors->attach('Test'); + $Apple->Behaviors->load('Test'); $expected = array_merge($current, array('mangle' => 'trigger mangled mangled')); $this->assertEquals($expected, $Apple->Behaviors->Test->settings['Apple']); - $Apple->Behaviors->attach('Test', array('mangle' => 'trigger')); + $Apple->Behaviors->load('Test', array('mangle' => 'trigger')); $expected = array_merge($current, array('mangle' => 'trigger mangled')); $this->assertEquals($expected, $Apple->Behaviors->Test->settings['Apple']); } @@ -586,18 +586,18 @@ public function testBehaviorBinding() { */ public function testDetachWithPluginNames() { $Apple = new Apple(); - $Apple->Behaviors->attach('Plugin.Test'); + $Apple->Behaviors->load('Plugin.Test'); $this->assertTrue(isset($Apple->Behaviors->Test), 'Missing behavior'); $this->assertEquals(array('Test'), $Apple->Behaviors->loaded()); - $Apple->Behaviors->detach('Plugin.Test'); + $Apple->Behaviors->unload('Plugin.Test'); $this->assertEquals(array(), $Apple->Behaviors->loaded()); - $Apple->Behaviors->attach('Plugin.Test'); + $Apple->Behaviors->load('Plugin.Test'); $this->assertTrue(isset($Apple->Behaviors->Test), 'Missing behavior'); $this->assertEquals(array('Test'), $Apple->Behaviors->loaded()); - $Apple->Behaviors->detach('Test'); + $Apple->Behaviors->unload('Test'); $this->assertEquals(array(), $Apple->Behaviors->loaded()); } @@ -609,7 +609,7 @@ public function testDetachWithPluginNames() { */ public function testInvalidBehaviorCausingCakeError() { $Apple = new Apple(); - $Apple->Behaviors->attach('NoSuchBehavior'); + $Apple->Behaviors->load('NoSuchBehavior'); } /** @@ -628,7 +628,7 @@ public function testBehaviorToggling() { $this->assertSame(array('Test'), $Apple->Behaviors->loaded()); $this->assertSame($Apple->Behaviors->enabled(), array()); - $Apple->Sample->Behaviors->attach('Test'); + $Apple->Sample->Behaviors->load('Test'); $this->assertTrue($Apple->Sample->Behaviors->enabled('Test')); $this->assertSame($Apple->Behaviors->enabled(), array()); @@ -638,11 +638,11 @@ public function testBehaviorToggling() { $Apple->Behaviors->disable('Test'); $this->assertSame($Apple->Behaviors->enabled(), array()); - $Apple->Behaviors->attach('Test', array('enabled' => true)); + $Apple->Behaviors->load('Test', array('enabled' => true)); $this->assertSame($Apple->Behaviors->enabled(), array('Test')); - $Apple->Behaviors->attach('Test', array('enabled' => false)); + $Apple->Behaviors->load('Test', array('enabled' => false)); $this->assertSame($Apple->Behaviors->enabled(), array()); - $Apple->Behaviors->detach('Test'); + $Apple->Behaviors->unload('Test'); $this->assertSame($Apple->Behaviors->enabled(), array()); } @@ -657,16 +657,16 @@ public function testBehaviorFindCallbacks() { $Apple = new Apple(); $expected = $Apple->find('all'); - $Apple->Behaviors->attach('Test'); + $Apple->Behaviors->load('Test'); $this->assertNull($Apple->find('all')); - $Apple->Behaviors->attach('Test', array('beforeFind' => 'off')); + $Apple->Behaviors->load('Test', array('beforeFind' => 'off')); $this->assertSame($expected, $Apple->find('all')); - $Apple->Behaviors->attach('Test', array('beforeFind' => 'test')); + $Apple->Behaviors->load('Test', array('beforeFind' => 'test')); $this->assertSame($expected, $Apple->find('all')); - $Apple->Behaviors->attach('Test', array('beforeFind' => 'modify')); + $Apple->Behaviors->load('Test', array('beforeFind' => 'modify')); $expected2 = array( array('Apple' => array('id' => '1', 'name' => 'Red Apple 1', 'mytime' => '22:57:17')), array('Apple' => array('id' => '2', 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')), @@ -679,19 +679,19 @@ public function testBehaviorFindCallbacks() { $result = $Apple->find('all'); $this->assertEquals($expected, $result); - $Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'afterFind' => 'on')); + $Apple->Behaviors->load('Test', array('beforeFind' => 'off', 'afterFind' => 'on')); $this->assertSame($Apple->find('all'), array()); - $Apple->Behaviors->attach('Test', array('afterFind' => 'off')); + $Apple->Behaviors->load('Test', array('afterFind' => 'off')); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Behaviors->attach('Test', array('afterFind' => 'test')); + $Apple->Behaviors->load('Test', array('afterFind' => 'test')); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Behaviors->attach('Test', array('afterFind' => 'test2')); + $Apple->Behaviors->load('Test', array('afterFind' => 'test2')); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Behaviors->attach('Test', array('afterFind' => 'modify')); + $Apple->Behaviors->load('Test', array('afterFind' => 'modify')); $expected = array( array('id' => '1', 'apple_id' => '2', 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'), array('id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17'), @@ -716,32 +716,32 @@ public function testBehaviorHasManyFindCallbacks() { $Apple->unbindModel(array('hasMany' => array('Child'))); $wellBehaved = $Apple->find('all'); - $Apple->Child->Behaviors->attach('Test', array('afterFind' => 'modify')); + $Apple->Child->Behaviors->load('Test', array('afterFind' => 'modify')); $Apple->unbindModel(array('hasMany' => array('Child'))); $this->assertSame($Apple->find('all'), $wellBehaved); - $Apple->Child->Behaviors->attach('Test', array('before' => 'off')); + $Apple->Child->Behaviors->load('Test', array('before' => 'off')); $this->assertSame($expected, $Apple->find('all')); - $Apple->Child->Behaviors->attach('Test', array('before' => 'test')); + $Apple->Child->Behaviors->load('Test', array('before' => 'test')); $this->assertSame($expected, $Apple->find('all')); - $Apple->Child->Behaviors->attach('Test', array('before' => 'modify')); + $Apple->Child->Behaviors->load('Test', array('before' => 'modify')); $result = $Apple->find('all', array('fields' => array('Apple.id'), 'conditions' => array('Apple.id <' => '4'))); $Apple->Child->Behaviors->disable('Test'); $result = $Apple->find('all'); $this->assertEquals($expected, $result); - $Apple->Child->Behaviors->attach('Test', array('before' => 'off', 'after' => 'on')); + $Apple->Child->Behaviors->load('Test', array('before' => 'off', 'after' => 'on')); - $Apple->Child->Behaviors->attach('Test', array('after' => 'off')); + $Apple->Child->Behaviors->load('Test', array('after' => 'off')); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Child->Behaviors->attach('Test', array('after' => 'test')); + $Apple->Child->Behaviors->load('Test', array('after' => 'test')); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Child->Behaviors->attach('Test', array('after' => 'test2')); + $Apple->Child->Behaviors->load('Test', array('after' => 'test2')); $this->assertEquals($expected, $Apple->find('all')); } @@ -757,27 +757,27 @@ public function testBehaviorHasOneFindCallbacks() { $Apple->unbindModel(array('hasOne' => array('Sample'))); $wellBehaved = $Apple->find('all'); - $Apple->Sample->Behaviors->attach('Test'); + $Apple->Sample->Behaviors->load('Test'); $Apple->unbindModel(array('hasOne' => array('Sample'))); $this->assertSame($Apple->find('all'), $wellBehaved); - $Apple->Sample->Behaviors->attach('Test', array('before' => 'off')); + $Apple->Sample->Behaviors->load('Test', array('before' => 'off')); $this->assertSame($expected, $Apple->find('all')); - $Apple->Sample->Behaviors->attach('Test', array('before' => 'test')); + $Apple->Sample->Behaviors->load('Test', array('before' => 'test')); $this->assertSame($expected, $Apple->find('all')); $Apple->Sample->Behaviors->disable('Test'); $result = $Apple->find('all'); $this->assertEquals($expected, $result); - $Apple->Sample->Behaviors->attach('Test', array('after' => 'off')); + $Apple->Sample->Behaviors->load('Test', array('after' => 'off')); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Sample->Behaviors->attach('Test', array('after' => 'test')); + $Apple->Sample->Behaviors->load('Test', array('after' => 'test')); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Sample->Behaviors->attach('Test', array('after' => 'test2')); + $Apple->Sample->Behaviors->load('Test', array('after' => 'test2')); $this->assertEquals($expected, $Apple->find('all')); } @@ -796,17 +796,17 @@ public function testBehaviorBelongsToFindCallbacks() { $Apple->unbindModel(array('belongsTo' => array('Parent'))); $wellBehaved = $Apple->find('all', $conditions); - $Apple->Parent->Behaviors->attach('Test'); + $Apple->Parent->Behaviors->load('Test'); $Apple->unbindModel(array('belongsTo' => array('Parent'))); $this->assertSame($Apple->find('all', $conditions), $wellBehaved); - $Apple->Parent->Behaviors->attach('Test', array('before' => 'off')); + $Apple->Parent->Behaviors->load('Test', array('before' => 'off')); $this->assertSame($expected, $Apple->find('all', $conditions)); - $Apple->Parent->Behaviors->attach('Test', array('before' => 'test')); + $Apple->Parent->Behaviors->load('Test', array('before' => 'test')); $this->assertSame($expected, $Apple->find('all', $conditions)); - $Apple->Parent->Behaviors->attach('Test', array('before' => 'modify')); + $Apple->Parent->Behaviors->load('Test', array('before' => 'modify')); $expected2 = array( array( 'Apple' => array('id' => 1), @@ -829,13 +829,13 @@ public function testBehaviorBelongsToFindCallbacks() { $result = $Apple->find('all', $conditions); $this->assertEquals($expected, $result); - $Apple->Parent->Behaviors->attach('Test', array('after' => 'off')); + $Apple->Parent->Behaviors->load('Test', array('after' => 'off')); $this->assertEquals($expected, $Apple->find('all', $conditions)); - $Apple->Parent->Behaviors->attach('Test', array('after' => 'test')); + $Apple->Parent->Behaviors->load('Test', array('after' => 'test')); $this->assertEquals($expected, $Apple->find('all', $conditions)); - $Apple->Parent->Behaviors->attach('Test', array('after' => 'test2')); + $Apple->Parent->Behaviors->load('Test', array('after' => 'test2')); $this->assertEquals($expected, $Apple->find('all', $conditions)); } @@ -848,25 +848,25 @@ public function testBehaviorSaveCallbacks() { $Sample = new Sample(); $record = array('Sample' => array('apple_id' => 6, 'name' => 'sample99')); - $Sample->Behaviors->attach('Test', array('beforeSave' => 'on')); + $Sample->Behaviors->load('Test', array('beforeSave' => 'on')); $Sample->create(); $this->assertSame(false, $Sample->save($record)); - $Sample->Behaviors->attach('Test', array('beforeSave' => 'off')); + $Sample->Behaviors->load('Test', array('beforeSave' => 'off')); $Sample->create(); $result = $Sample->save($record); $expected = $record; $expected['Sample']['id'] = $Sample->id; $this->assertSame($expected, $result); - $Sample->Behaviors->attach('Test', array('beforeSave' => 'test')); + $Sample->Behaviors->load('Test', array('beforeSave' => 'test')); $Sample->create(); $result = $Sample->save($record); $expected = $record; $expected['Sample']['id'] = $Sample->id; $this->assertSame($expected, $result); - $Sample->Behaviors->attach('Test', array('beforeSave' => 'modify')); + $Sample->Behaviors->load('Test', array('beforeSave' => 'modify')); $expected = Hash::insert($record, 'Sample.name', 'sample99 modified before'); $Sample->create(); $result = $Sample->save($record); @@ -876,21 +876,21 @@ public function testBehaviorSaveCallbacks() { $Sample->Behaviors->disable('Test'); $this->assertSame($record, $Sample->save($record)); - $Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'on')); + $Sample->Behaviors->load('Test', array('beforeSave' => 'off', 'afterSave' => 'on')); $expected = Hash::merge($record, array('Sample' => array('aftersave' => 'modified after on create'))); $Sample->create(); $result = $Sample->save($record); $expected['Sample']['id'] = $Sample->id; $this->assertEquals($expected, $result); - $Sample->Behaviors->attach('Test', array('beforeSave' => 'modify', 'afterSave' => 'modify')); + $Sample->Behaviors->load('Test', array('beforeSave' => 'modify', 'afterSave' => 'modify')); $expected = Hash::merge($record, array('Sample' => array('name' => 'sample99 modified before modified after on create'))); $Sample->create(); $result = $Sample->save($record); $expected['Sample']['id'] = $Sample->id; $this->assertSame($expected, $result); - $Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'test')); + $Sample->Behaviors->load('Test', array('beforeSave' => 'off', 'afterSave' => 'test')); $Sample->create(); $expected = $record; unset($expected['Sample']['name']); @@ -898,23 +898,23 @@ public function testBehaviorSaveCallbacks() { $expected['Sample']['id'] = $Sample->id; $this->assertSame($expected, $result); - $Sample->Behaviors->attach('Test', array('afterSave' => 'test2')); + $Sample->Behaviors->load('Test', array('afterSave' => 'test2')); $Sample->create(); $expected = $record; $result = $Sample->save($record); $expected['Sample']['id'] = $Sample->id; $this->assertSame($expected, $result); - $Sample->Behaviors->attach('Test', array('beforeFind' => 'off', 'afterFind' => 'off')); + $Sample->Behaviors->load('Test', array('beforeFind' => 'off', 'afterFind' => 'off')); $Sample->recursive = -1; $record2 = $Sample->read(null, 1); - $Sample->Behaviors->attach('Test', array('afterSave' => 'on')); + $Sample->Behaviors->load('Test', array('afterSave' => 'on')); $expected = Hash::merge($record2, array('Sample' => array('aftersave' => 'modified after'))); $Sample->create(); $this->assertSame($expected, $Sample->save($record2)); - $Sample->Behaviors->attach('Test', array('afterSave' => 'modify')); + $Sample->Behaviors->load('Test', array('afterSave' => 'modify')); $expected = Hash::merge($record2, array('Sample' => array('name' => 'sample1 modified after'))); $Sample->create(); $this->assertSame($expected, $Sample->save($record2)); @@ -928,13 +928,13 @@ public function testBehaviorSaveCallbacks() { public function testBehaviorDeleteCallbacks() { $Apple = new Apple(); - $Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'beforeDelete' => 'off')); + $Apple->Behaviors->load('Test', array('beforeFind' => 'off', 'beforeDelete' => 'off')); $this->assertTrue($Apple->delete(6)); - $Apple->Behaviors->attach('Test', array('beforeDelete' => 'on')); + $Apple->Behaviors->load('Test', array('beforeDelete' => 'on')); $this->assertFalse($Apple->delete(4)); - $Apple->Behaviors->attach('Test', array('beforeDelete' => 'test2')); + $Apple->Behaviors->load('Test', array('beforeDelete' => 'test2')); ob_start(); $results = $Apple->delete(4); @@ -946,7 +946,7 @@ public function testBehaviorDeleteCallbacks() { $this->assertSame(trim(ob_get_clean()), 'beforeDelete success'); $this->assertTrue($results); - $Apple->Behaviors->attach('Test', array('beforeDelete' => 'off', 'afterDelete' => 'on')); + $Apple->Behaviors->load('Test', array('beforeDelete' => 'off', 'afterDelete' => 'on')); ob_start(); $results = $Apple->delete(2, false); $this->assertSame(trim(ob_get_clean()), 'afterDelete success'); @@ -961,7 +961,7 @@ public function testBehaviorDeleteCallbacks() { public function testBehaviorOnErrorCallback() { $Apple = new Apple(); - $Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'onError' => 'on')); + $Apple->Behaviors->load('Test', array('beforeFind' => 'off', 'onError' => 'on')); ob_start(); $Apple->Behaviors->Test->onError($Apple, ''); $this->assertSame(trim(ob_get_clean()), 'onError trigger success'); @@ -975,18 +975,18 @@ public function testBehaviorOnErrorCallback() { public function testBehaviorValidateCallback() { $Apple = new Apple(); - $Apple->Behaviors->attach('Test'); + $Apple->Behaviors->load('Test'); $this->assertTrue($Apple->validates()); - $Apple->Behaviors->attach('Test', array('validate' => 'on')); + $Apple->Behaviors->load('Test', array('validate' => 'on')); $this->assertFalse($Apple->validates()); $this->assertSame($Apple->validationErrors, array('name' => array(true))); - $Apple->Behaviors->attach('Test', array('validate' => 'stop')); + $Apple->Behaviors->load('Test', array('validate' => 'stop')); $this->assertFalse($Apple->validates()); $this->assertSame($Apple->validationErrors, array('name' => array(true, true))); - $Apple->Behaviors->attach('Test', array('validate' => 'whitelist')); + $Apple->Behaviors->load('Test', array('validate' => 'whitelist')); $Apple->validates(); $this->assertSame($Apple->whitelist, array()); @@ -1003,14 +1003,14 @@ public function testBehaviorValidateCallback() { public function testBehaviorValidateAfterCallback() { $Apple = new Apple(); - $Apple->Behaviors->attach('Test'); + $Apple->Behaviors->load('Test'); $this->assertTrue($Apple->validates()); - $Apple->Behaviors->attach('Test', array('afterValidate' => 'on')); + $Apple->Behaviors->load('Test', array('afterValidate' => 'on')); $this->assertTrue($Apple->validates()); $this->assertSame($Apple->validationErrors, array()); - $Apple->Behaviors->attach('Test', array('afterValidate' => 'test')); + $Apple->Behaviors->load('Test', array('afterValidate' => 'test')); $Apple->data = array('bar'); $Apple->validates(); $this->assertEquals(array('foo'), $Apple->data); @@ -1023,7 +1023,7 @@ public function testBehaviorValidateAfterCallback() { */ public function testBehaviorValidateMethods() { $Apple = new Apple(); - $Apple->Behaviors->attach('Test'); + $Apple->Behaviors->load('Test'); $Apple->validate['color'] = 'validateField'; $result = $Apple->save(array('name' => 'Genetically Modified Apple', 'color' => 'Orange')); @@ -1041,7 +1041,7 @@ public function testBehaviorValidateMethods() { */ public function testBehaviorMethodDispatching() { $Apple = new Apple(); - $Apple->Behaviors->attach('Test'); + $Apple->Behaviors->load('Test'); $expected = 'working'; $this->assertEquals($expected, $Apple->testMethod()); @@ -1066,7 +1066,7 @@ public function testBehaviorMethodDispatching() { */ public function testBehaviorMethodDispatchingWithData() { $Apple = new Apple(); - $Apple->Behaviors->attach('Test'); + $Apple->Behaviors->load('Test'); $Apple->set('field', 'value'); $this->assertTrue($Apple->testData()); @@ -1087,7 +1087,7 @@ public function testBindModelCallsInBehaviors() { $result = $Article->find('first'); $this->assertFalse(array_key_exists('Comment', $result)); - $Article->Behaviors->attach('Test4'); + $Article->Behaviors->load('Test4'); $result = $Article->find('first'); $this->assertTrue(array_key_exists('Comment', $result)); @@ -1096,7 +1096,7 @@ public function testBindModelCallsInBehaviors() { $result = $Article->find('first'); $this->assertFalse(array_key_exists('User', $result)); - $Article->Behaviors->attach('Test5'); + $Article->Behaviors->load('Test5'); $result = $Article->find('first'); $this->assertTrue(array_key_exists('User', $result)); @@ -1105,7 +1105,7 @@ public function testBindModelCallsInBehaviors() { $result = $Article->find('first'); $this->assertFalse(array_key_exists('Tag', $result)); - $Article->Behaviors->attach('Test6'); + $Article->Behaviors->load('Test6'); $result = $Article->find('first'); $this->assertTrue(array_key_exists('Comment', $result)); @@ -1115,7 +1115,7 @@ public function testBindModelCallsInBehaviors() { $result = $Comment->find('first'); $this->assertFalse(array_key_exists('Attachment', $result)); - $Comment->Behaviors->attach('Test7'); + $Comment->Behaviors->load('Test7'); $result = $Comment->find('first'); $this->assertTrue(array_key_exists('Attachment', $result)); } @@ -1129,8 +1129,8 @@ public function testBehaviorAttachAndDetach() { $Sample = new Sample(); $Sample->actsAs = array('Test3' => array('bar'), 'Test2' => array('foo', 'bar')); $Sample->Behaviors->init($Sample->alias, $Sample->actsAs); - $Sample->Behaviors->attach('Test2'); - $Sample->Behaviors->detach('Test3'); + $Sample->Behaviors->load('Test2'); + $Sample->Behaviors->unload('Test3'); $Sample->Behaviors->trigger('beforeTest', array(&$Sample)); } diff --git a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php index ff7e52d8ee8..cbe20026cff 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -212,7 +212,7 @@ public function testDynamicBehaviorAttachment() { $TestModel = new Apple(); $this->assertEquals(array(), $TestModel->Behaviors->loaded()); - $TestModel->Behaviors->attach('Tree', array('left' => 'left_field', 'right' => 'right_field')); + $TestModel->Behaviors->load('Tree', array('left' => 'left_field', 'right' => 'right_field')); $this->assertTrue(is_object($TestModel->Behaviors->Tree)); $this->assertEquals(array('Tree'), $TestModel->Behaviors->loaded()); @@ -227,11 +227,11 @@ public function testDynamicBehaviorAttachment() { ); $this->assertEquals($expected, $TestModel->Behaviors->Tree->settings['Apple']); - $TestModel->Behaviors->attach('Tree', array('enabled' => false)); + $TestModel->Behaviors->load('Tree', array('enabled' => false)); $this->assertEquals($expected, $TestModel->Behaviors->Tree->settings['Apple']); $this->assertEquals(array('Tree'), $TestModel->Behaviors->loaded()); - $TestModel->Behaviors->detach('Tree'); + $TestModel->Behaviors->unload('Tree'); $this->assertEquals(array(), $TestModel->Behaviors->loaded()); $this->assertFalse(isset($TestModel->Behaviors->Tree)); } diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index d313a33df12..6a042b3a29b 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -1720,7 +1720,7 @@ public function testGetMethodsRefresh() { $expected = array_map('strtolower', get_class_methods('Article')); $this->assertEquals($expected, array_keys($result)); - $TestModel->Behaviors->attach('Containable'); + $TestModel->Behaviors->load('Containable'); $newList = array( 'contain', 'resetbindings', @@ -1730,7 +1730,7 @@ public function testGetMethodsRefresh() { ); $this->assertEquals(array_merge($expected, $newList), array_keys($Validator->getMethods())); - $TestModel->Behaviors->detach('Containable'); + $TestModel->Behaviors->unload('Containable'); $this->assertEquals($expected, array_keys($Validator->getMethods())); }