Example #1
0
 public function testGetClient()
 {
     $client = $this->connection->getClient();
     $this->assertInstanceOf('Everyman\\Neo4j\\Client', $client);
     $endPoint = $client->getTransport()->getEndpoint();
     $this->assertEquals('http://localhost:7474/db/data', $endPoint);
 }
Example #2
0
 /**
  * Loads data from remote server and stores it
  */
 protected function loadData()
 {
     $client = $this->connection->getClient();
     $cache = [];
     $data = $this->retrieveFromRemote();
     if (!$data) {
         throw new \Exception('Could not retrieve data from remote');
     }
     foreach ($data as $item) {
         $person = $client->makeNode()->setProperty('id', $item['id'])->setProperty('firstName', $item['firstName'])->setProperty('surname', $item['surname'])->setProperty('age', $item['age'])->setProperty('gender', 'male')->save();
         $cache[$person->getProperty('id')] = ['person' => $person, 'friends' => $item['friends']];
     }
     $excluded = [];
     foreach ($cache as $id => $info) {
         $person = $info['person'];
         foreach ($info['friends'] as $friendId) {
             if (!in_array($friendId, $excluded)) {
                 $person->relateTo($cache[$friendId]['person'], 'FRIEND')->save();
             }
         }
         $excluded[] = $id;
     }
 }
Example #3
0
 /**
  * Execute Cypher query and return result
  *
  * @param string $query
  *
  * @return \Everyman\Neo4j\Query\ResultSet
  */
 protected function getResult($query)
 {
     return $this->connection->executeQuery($query);
 }
Example #4
0
 protected function setUp()
 {
     $this->connection = $this->getMockBuilder('Krlove\\Storage\\Connection')->disableOriginalConstructor()->getMock();
     $this->connection->expects($this->any())->method('executeQuery')->willReturnArgument(0);
     $this->repository = new FriendRepository($this->connection);
 }