Skip to content

Commit

Permalink
Can retrieve labels for node 0. Closes jadell#110
Browse files Browse the repository at this point in the history
  • Loading branch information
jadell committed Mar 1, 2014
1 parent 18ccf02 commit d63b62a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Everyman/Neo4j/Command/GetLabels.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function getPath()
$path = "/labels";
if ($this->node) {
$id = $this->node->getId();
if (!$id) {
if (!is_numeric($id)) {
throw new \InvalidArgumentException("Node given with no id");
}

Expand Down
21 changes: 21 additions & 0 deletions tests/unit/lib/Everyman/Neo4j/Client_LabelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,27 @@ public function testGetLabels_NodeSpecified_ReturnsArrayOfLabelsAttachedToNode()
}
}

public function testGetLabels_NodeIdZero_ReturnsArrayOfLabelsAttachedToNode()
{
$nodeId = 0;
$node = new Node($this->client);
$node->setId($nodeId);

$returnData = array('FOOBAR', 'BAZQUX');

$this->transport->expects($this->once())
->method('get')
->with("/node/{$nodeId}/labels")
->will($this->returnValue(array('code'=>200,'data'=>$returnData)));

$labels = $this->client->getLabels($node);
self::assertEquals(count($returnData), count($labels));
foreach ($labels as $i => $label) {
self::assertInstanceOf('Everyman\Neo4j\Label', $label);
self::assertEquals($returnData[$i], $label->getName());
}
}

public function testGetLabels_NoNodeId_ThrowsException()
{
$node = new Node($this->client);
Expand Down

0 comments on commit d63b62a

Please sign in to comment.