|
|
@@ -523,7 +523,7 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
);
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
*/
|
|
|
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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
*/
|
|
|
public function testInvalidBehaviorCausingCakeError() {
|
|
|
$Apple = new Apple();
|
|
|
- $Apple->Behaviors->attach('NoSuchBehavior');
|
|
|
+ $Apple->Behaviors->load('NoSuchBehavior');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -628,7 +628,7 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
*/
|
|
|
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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
*/
|
|
|
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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
*/
|
|
|
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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|
|
$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));
|
|
|
}
|