Skip to content

Commit 2d779ac

Browse files
committed
1 parent c1c8ca9 commit 2d779ac

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/QueryBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ public function moveNode($key, $position)
450450
{
451451
list($lft, $rgt) = $this->model->newServiceQuery()->getPlainNodeData($key, true);
452452

453-
if ($lft < $position && $position < $rgt)
453+
if ($lft < $position && $position <= $rgt)
454454
{
455455
throw new LogicException('Cannot move node into itself.');
456456
}

tests/NodeTest.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,34 @@ public function testCategoryMovesUp()
211211
/**
212212
* @expectedException Exception
213213
*/
214-
public function testFailsToInsertIntoItself()
214+
public function testFailsToInsertIntoChild()
215215
{
216216
$node = $this->findCategory('notebooks');
217217
$target = $node->children()->first();
218218

219219
$node->afterNode($target)->save();
220220
}
221221

222+
/**
223+
* @expectedException Exception
224+
*/
225+
public function testFailsToAppendIntoItself()
226+
{
227+
$node = $this->findCategory('notebooks');
228+
229+
$node->appendTo($node)->save();
230+
}
231+
232+
/**
233+
* @expectedException Exception
234+
*/
235+
public function testFailsToPrependIntoItself()
236+
{
237+
$node = $this->findCategory('notebooks');
238+
239+
$node->prependTo($node)->save();
240+
}
241+
222242
public function testWithoutRootWorks()
223243
{
224244
$result = Category::withoutRoot()->pluck('name');

0 commit comments

Comments
 (0)