Skip to content

Commit

Permalink
Fixing issues found in review
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 31, 2014
1 parent b5d4ac4 commit bb439ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Model/Behavior/TreeBehavior.php
Expand Up @@ -131,7 +131,7 @@ public function beforeDelete(Event $event, Entity $entity) {
]);
}

$this->_sync($diff, '-' , "> {$right}");
$this->_sync($diff, '-', "> {$right}");
}

/**
Expand Down Expand Up @@ -569,19 +569,19 @@ protected function _getMin() {
*/
protected function _getMaxOrMin($maxOrMin = 'max') {
$config = $this->config();
$lOrR = $maxOrMin === 'max' ? $config['right'] : $config['left'];
$dOrA = $maxOrMin === 'max' ? 'DESC' : 'ASC';
$field = $maxOrMin === 'max' ? $config['right'] : $config['left'];
$direction = $maxOrMin === 'max' ? 'DESC' : 'ASC';

$edge = $this->_scope($this->_table->find())
->select([$lOrR])
->order([$lOrR => $dOrA])
->select([$field])
->order([$field => $direction])
->first();

if (empty($edge->{$lOrR})) {
if (empty($edge->{$field})) {
return 0;
}

return $edge->{$lOrR};
return $edge->{$field};
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/Model/Behavior/TreeBehaviorTest.php
Expand Up @@ -37,6 +37,7 @@ class TreeBehaviorTest extends TestCase {
];

public function setUp() {
parent::setUp();
$this->table = TableRegistry::get('NumberTrees');
$this->table->addBehavior('Tree');
}
Expand Down

0 comments on commit bb439ff

Please sign in to comment.