/** * Action for sending friend request. * * @param Request $request * @param $id * @return Response */ public function sendFriendRequest(Request $request, $id) { $fromUser = $this->_nodeRepository->getNodeById($id); $toUser = $this->_nodeRepository->getNodeById($request->get('userid')); $relationship = $fromUser->relateTo($toUser, 'PENDING')->save(); return new Response(['id' => $relationship->getId()], Response::HTTP_OK); }
public function testGetNodeById() { $nodeId = 15; $node = m::mock('Everyman\\Neo4j\\Node'); $client = m::mock('Everyman\\Neo4j\\Client'); $client->shouldReceive('getNode')->once()->with($nodeId)->andReturn($node); $neo4j = m::mock('App\\Services\\Neo4j'); $neo4j->shouldReceive('getClient')->once()->andReturn($client); $nodeRepository = new Node($neo4j); $this->assertEquals($node, $nodeRepository->getNodeById($nodeId)); }