File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -252,8 +252,11 @@ public function isAncestor(int $id): bool
252252 */
253253 public function getAncestor (int $ id )
254254 {
255- if ($ this ->parent !== null && $ this ->parent ->id () == $ id ) {
256- return $ this ->parent ;
255+ if ($ this ->parent !== null ) {
256+ if ($ this ->parent ->id () == $ id ) {
257+ return $ this ->parent ;
258+ }
259+ return $ this ->parent ->getAncestor ($ id );
257260 }
258261 return null ;
259262 }
Original file line number Diff line number Diff line change @@ -301,6 +301,7 @@ public function testGetGreatAncestor()
301301 $ parent ->addChild ($ child );
302302 $ child ->addChild ($ child2 );
303303 $ ancestor = $ child2 ->getAncestor ($ parent ->id ());
304+ $ this ->assertNotNull ($ ancestor );
304305 $ this ->assertEquals ($ parent ->id (), $ ancestor ->id ());
305306 }
306307
You can’t perform that action at this time.
0 commit comments