public function testGetIntersectingNode()
 {
     $n1 = new Node("one");
     $n2 = new Node("two");
     $n3 = new Node("three");
     $n4 = new Node("four");
     $n5 = new Node("five");
     $n1->setNext($n2);
     $n2->setNext($n3);
     $n3->setNext($n4);
     $n4->setNext($n5);
     $this->assertNull(LinkedListCycleDetector::getCycleNode($n1));
     // create a cycle
     $n5->setNext($n3);
     $this->assertSame($n3, LinkedListCycleDetector::getCycleNode($n1));
 }
 public function testFindBeginningOfCycleWithCircularListOfSizeFive()
 {
     $n1 = new Node("one");
     $n2 = new Node("two");
     $n3 = new Node("three");
     $n4 = new Node("four");
     $n5 = new Node("five");
     $n1->setNext($n2);
     $n2->setNext($n3);
     $n3->setNext($n4);
     $n4->setNext($n5);
     $n5->setNext($n1);
     $cycleNode = LinkedListCycleDetector::findBeginningOfCycle($n1);
     $this->assertSame($n1, $cycleNode, 'Expected: ' . $n1->getData() . ' Found: ' . $cycleNode->getData());
 }