예제 #1
0
 function it_should_define_percentage_of_target_nodes(ObjectCollection $collection, Relationship $relationship)
 {
     $collection->count()->willReturn(100);
     $relationship->hasPercentage()->willReturn(false);
     $relationship->getEndNode()->willReturn('person');
     $this->getTargetNodesCount($relationship, $collection)->shouldBe(60);
     $collection->count()->willReturn(1);
     $relationship->hasPercentage()->willReturn(false);
     $relationship->getEndNode()->willReturn('person');
     $this->getTargetNodesCount($relationship, $collection)->shouldBe(1);
     $collection->count()->willReturn(1000);
     $relationship->hasPercentage()->willReturn(false);
     $this->getTargetNodesCount($relationship, $collection)->shouldBe(200);
     $collection->count()->willReturn(100);
     $relationship->hasPercentage()->willReturn(true);
     $relationship->getPercentage()->willReturn(65);
     $this->getTargetNodesCount($relationship, $collection)->shouldBe(65);
     $collection->count()->willReturn(1000);
     $relationship->hasPercentage()->willReturn(true);
     $relationship->getPercentage()->willReturn(45);
     $this->getTargetNodesCount($relationship, $collection)->shouldBe(450);
 }
예제 #2
0
 /**
  * @param  ObjectCollection $nodes
  * @return mixed|null
  */
 private function getRandomNode(ObjectCollection $nodes)
 {
     $max = $nodes->count();
     $i = rand(0, $max - 1);
     return $nodes->get($i);
 }