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); }
/** * 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; } }