Skip to content

Commit

Permalink
URL encode relationship types to account for URL chars in type names.
Browse files Browse the repository at this point in the history
Closes #132
  • Loading branch information
jadell committed Mar 13, 2014
1 parent d63b62a commit 6ca33b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Everyman/Neo4j/Command/GetNodeRelationships.php
Expand Up @@ -75,7 +75,8 @@ protected function getPath()

$path = '/node/'.$this->node->getId().'/relationships/'.$this->dir;
if (!empty($this->types)) {
$path .= '/'.join('&', $this->types);
$types = array_map('rawurlencode', $this->types);
$path .= '/'.join('&', $types);
}

return $path;
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/lib/Everyman/Neo4j/ClientTest.php
Expand Up @@ -754,6 +754,20 @@ public function testGetNodeRelationships_Relationships_ReturnsArray()
$this->assertEquals(123, $result[1]->getEndNode()->getId());
}

public function testGetNodeRelationships_UrlCharactersInTypeName_EncodesCorrectly()
{
$node = new Node($this->client);
$node->setId(123);
$types = array('FOO\TYPE','BAR?TYPE','BAZ/TYPE');

$this->transport->expects($this->once())
->method('get')
->with('/node/123/relationships/all/FOO%5CTYPE&BAR%3FTYPE&BAZ%2FTYPE')
->will($this->returnValue(array('code'=>200,'data'=>array())));

$result = $this->client->getNodeRelationships($node, $types);
}

public function testGetRelationshipTypes_ServerReturnsErrorCode_ThrowsException()
{
$this->transport->expects($this->once())
Expand Down

0 comments on commit 6ca33b2

Please sign in to comment.