File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -230,6 +230,9 @@ public function getTree() {
230230 * {@inheritdoc}
231231 */
232232 public function deleteNode (Node $ node ) {
233+ if ($ node ->getLeft () < 1 || $ node ->getRight () < 1 ) {
234+ throw new \InvalidArgumentException ("Left and right values must be > 0 " );
235+ }
233236 $ left = $ node ->getLeft ();
234237 $ right = $ node ->getRight ();
235238 $ width = $ right - $ left + 1 ;
Original file line number Diff line number Diff line change @@ -281,6 +281,16 @@ public function testDeleteNode() {
281281 $ tree = $ this ->nestedSet ->getTree ();
282282 }
283283
284+ /**
285+ * Tests deleting a node with missing values.
286+ *
287+ * @expectedException \InvalidArgumentException
288+ */
289+ public function testDeleteNodeInvalid () {
290+ $ node = new Node (1 , 1 );
291+ $ this ->nestedSet ->deleteNode ($ node );
292+ }
293+
284294 /**
285295 * Tests deleting a node and its sub-tree.
286296 */
You can’t perform that action at this time.
0 commit comments