mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing ModelBehavior::detach() when non 0 index behaviors are detatched. Tests Added.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7862 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
6285f0cb6d
commit
eccfea3429
2 changed files with 17 additions and 1 deletions
|
@ -329,7 +329,7 @@ class BehaviorCollection extends Object {
|
|||
unset($this->__methods[$m]);
|
||||
}
|
||||
}
|
||||
$this->_attached = array_diff($this->_attached, (array)$name);
|
||||
$this->_attached = array_values(array_diff($this->_attached, (array)$name));
|
||||
}
|
||||
/**
|
||||
* Enables callbacks on a behavior or array of behaviors
|
||||
|
|
|
@ -932,6 +932,22 @@ class BehaviorTest extends CakeTestCase {
|
|||
$expected = array('TestBehavior', 'Test2Behavior');
|
||||
$this->assertIdentical($Apple->beforeTestResult, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test attach and detaching
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
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->trigger($Apple, 'beforeTest');
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue