mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
parent
6c905411ba
commit
a7c79e5da2
2 changed files with 17 additions and 3 deletions
|
@ -124,11 +124,13 @@ class TreeBehavior extends ModelBehavior {
|
|||
*/
|
||||
public function beforeDelete(Model $Model, $cascade = true) {
|
||||
extract($this->settings[$Model->alias]);
|
||||
$data = current($Model->find('first', array(
|
||||
$data = $Model->find('first', array(
|
||||
'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id),
|
||||
'fields' => array($Model->alias . '.' . $left, $Model->alias . '.' . $right),
|
||||
'recursive' => -1)));
|
||||
$this->_deletedRow = $data;
|
||||
'recursive' => -1));
|
||||
if ($data) {
|
||||
$this->_deletedRow = current($data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -914,6 +914,18 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
|||
$this->assertSame($validTree, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting a record that doesn't exist.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDeleteDoesNotExist() {
|
||||
extract($this->settings);
|
||||
$this->Tree = new $modelClass();
|
||||
$this->Tree->initialize(2, 2);
|
||||
$this->Tree->delete(99999);
|
||||
}
|
||||
|
||||
/**
|
||||
* testRemove method
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue