public function testCommitBatch_CreateNode_Success_ReturnsTrue() { $node = new Node($this->client); $node->setProperties(array('foo' => 'bar', 'baz' => 'qux')); $request = array(array('id' => 0, 'method' => 'POST', 'to' => '/node', 'body' => array('foo' => 'bar', 'baz' => 'qux'))); $return = array('code' => 200, 'data' => array(array('id' => 0, 'location' => 'http://foo:1234/db/data/node/123'))); $this->batch->save($node); $this->setupTransportExpectation($request, $this->returnValue($return)); $result = $this->client->commitBatch($this->batch); $this->assertTrue($result); $this->assertEquals(123, $node->getId()); $this->assertSame($node, $this->client->getEntityCache()->getCachedEntity(123, 'node')); }
public function testSaveNode_Create_TransportError_ThrowsException() { $properties = array('foo' => 'bar', 'baz' => 'qux'); $node = new Node($this->client); $node->setProperties($properties); $this->transport->expects($this->once())->method('post')->with('/node', $properties)->will($this->returnValue(array('code' => 400))); $this->setExpectedException('Everyman\\Neo4j\\Exception'); $this->client->saveNode($node); }
/** * Load the given node with data from the server * * @param Node $node * @return boolean */ public function loadNode(Node $node) { $cached = $this->getEntityCache()->getCachedEntity($node->getId(), 'node'); if ($cached) { $node->setProperties($cached->getProperties()); return true; } return $this->runCommand(new Command\GetNode($this, $node)); }
public static function inflateFromResponse($neo_db, $response) { $node = new Node($neo_db); $node->_is_new = FALSE; $node->_id = end(explode("/", $response['self'])); $node->setProperties($response['data']); return $node; }
/** * Fill a node with data * * @param Node $node * @param array $data * @return Node */ public function populateNode(Node $node, $data) { $node->useLazyLoad(false); $node->setProperties($data['data']); return $node; }
/** * @static * @param Database $db * @param array $response * @return Node */ public static function inflateFromResponse($db, $response) { $self_path = explode("/", $response['self']); $node = new Node($db); $node->_is_new = false; $node->_id = end($self_path); $node->setProperties($response['data']); return $node; }