@@ -119,10 +119,13 @@ public function testRecievesValidValuesWhenAppendedTo()
119
119
$ node = new Category ([ 'name ' => 'test ' ]);
120
120
$ root = Category::root ();
121
121
122
+ $ accepted = array ($ root ->_rgt , $ root ->_rgt + 1 , $ root ->id );
123
+
122
124
$ root ->append ($ node );
123
125
124
- $ this ->assertEquals (array ( $ root -> _rgt , $ root -> _rgt + 1 , $ root -> id ) , $ this ->nodeValues ($ node ));
126
+ $ this ->assertEquals ($ accepted , $ this ->nodeValues ($ node ));
125
127
$ this ->assertTreeNotBroken ();
128
+ $ this ->assertFalse ($ node ->isDirty ());
126
129
}
127
130
128
131
public function testRecievesValidValuesWhenPrependedTo ()
@@ -143,6 +146,7 @@ public function testRecievesValidValuesWhenInsertedAfter()
143
146
144
147
$ this ->assertEquals (array ($ target ->_rgt + 1 , $ target ->_rgt + 2 , $ target ->parent ->id ), $ this ->nodeValues ($ node ));
145
148
$ this ->assertTreeNotBroken ();
149
+ $ this ->assertFalse ($ node ->isDirty ());
146
150
}
147
151
148
152
public function testRecievesValidValuesWhenInsertedBefore ()
@@ -446,6 +450,15 @@ public function testCreatesNode()
446
450
$ this ->assertEquals (19 , $ node ->getLft ());
447
451
}
448
452
453
+ public function testCreatesViaRelationship ()
454
+ {
455
+ $ node = $ this ->findCategory ('apple ' );
456
+
457
+ $ child = $ node ->children ()->create ([ 'name ' => 'test ' ]);
458
+
459
+ $ this ->assertTreeNotBroken ();
460
+ }
461
+
449
462
public function testCreatesTree ()
450
463
{
451
464
$ node = Category::create (
@@ -454,10 +467,12 @@ public function testCreatesTree()
454
467
'children ' =>
455
468
[
456
469
[ 'name ' => 'test2 ' ],
470
+ [ 'name ' => 'test3 ' ],
457
471
],
458
472
]);
459
473
474
+ $ this ->assertTreeNotBroken ();
460
475
$ this ->assertTrue (isset ($ node ->children ));
461
- $ this ->assertCount (1 , $ node ->children );
476
+ $ this ->assertCount (2 , $ node ->children );
462
477
}
463
478
}
0 commit comments